0

我创建了一个表格。我想做一个后保存方法。

他记录但记录相同的数据两次。我怎么解决这个问题?

我必须解决双重注册问题。我按了一次按钮。当我逐步进行调试时,它在同一行上运行了两次。当我将数据库控制为自上而下时,我看到您重复登录。

HTML:

<div class="portlet-body form">
       @using (Ajax.BeginForm("TalepTurKaydet", "MasterEducationController",
         new AjaxOptions { HttpMethod = "post", OnSuccess = "TalepTurKaydet" },
                                                            new { @class = "" }))
        {
            @Html.ValidationSummary(true)
            <div class="form-body">
                <div class="row">               
                    <div class="col-md-12" style="margin-left: 20px">

                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-3">Açıklama: </label>
                            <div class="col-md-9">
                                <textarea id="Aciklama" name="Aciklama" class="col-md-12" style="resize: none;" rows="5" placeholder="Açıklama"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="clearfix"></div><br /><br />
                </div>
                <div class=" form-actions right">
                    <button type="button" class="btn green btnPrevious"><i class="fa fa-angle-double-left"></i>Geri</button>
                    <button id="talepOlustur" type="submit" class="btn blue"><i class="fa fa-check"></i> Talep Oluştur</button>
                </div>
            </div>
        }
    </div>

控制器:

public ActionResult MezuniyetBilgiKaydet(MezuniyetBilgi model)
        {
            List<MezuniyetBilgi> list = null;
            model.KullaniciId = GetUye().kullaniciID;
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(ApiAdress.API_URL);

                var responseTask = client.PostAsJsonAsync("apiMasterProgramEducation/MezuniyetBilgiKaydet", model);
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync<List<MezuniyetBilgi>>();
                    readTask.Wait();

                    list = readTask.Result;
                    model = list.FirstOrDefault();

                    return Json(new
                    {
                        Success = true,
                        data = model,
                        Message = SuccessMessage.MEZUNIYET_BILGISI_INSERT_MESSAGE,
                        JsonRequestBehavior.AllowGet
                    });

                }

            }
        }

接口:

   public IHttpActionResult MezuniyetBilgiKaydet(MezuniyetBilgi model)
        {
            List<MezuniyetBilgi> detay = new List<MezuniyetBilgi>();
            try
            {
                using (var ctx = new ktdbEntities())
                {
                    if (model != null)
                    {
                        var query = ctx.mezuniyetBilgisiEkle(model.KullaniciId, model.MezuniyetTarih, model.MezunOlduguOkul,
                            model.MezunOlduguFakulte, model.MezunOlduguBolum, (float)(model.MezuniyetNotu));

                        model.Output = true;
                        detay.Add(model);
                        return Ok(detay);
                    }

                }
            }
            catch (Exception e)
            {
                model.Output = false;
                model.Message = e.Message;
                detay.Add(model);

            }
            return Ok(detay);
        }
4

0 回答 0