public ActionResult PartnersSpec_save() { var parameters = AjaxModel.GetAjaxParameters(HttpContext); var mng = new PartnersManager(); try { var fields = (parameters["fields"] as ArrayList).ToArray().ToList().Select(x => x as Dictionary <string, object>).ToList(); var newPartnerSpec = new ps_specs { id = (AjaxModel.GetValueFromSaveField("id", fields) == "") ? 0 : int.Parse(AjaxModel.GetValueFromSaveField("id", fields)), name = (AjaxModel.GetValueFromSaveField("name", fields)), }; mng.SavePartnersSpec(newPartnerSpec); return(Json(new { result = true, id = newPartnerSpec.id, mng = "Операция прошла успешно" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { RDL.Debug.LogError(ex); return(Json(new { result = false, id = 0, mng = "Ошибка" }, JsonRequestBehavior.AllowGet)); } }
public ps_specs GetPartnersSpec(int id) { var res = new ps_specs(); res = db.GetPartnersSpec(id); return(res); }
public int SavePartnersSpec(ps_specs element) { try { if (element.id == 0) { db.ps_specs.Add(element); db.SaveChanges(); } else { try { db.Entry(element).State = EntityState.Modified; db.SaveChanges(); } catch (OptimisticConcurrencyException ex) { RDL.Debug.LogError(ex); } } } catch (Exception ex) { RDL.Debug.LogError(ex); } return(element.id); }
// public ps_specs GetPartnersSpec(int id) { var res = new ps_specs(); res = db.ps_specs.FirstOrDefault(partner => partner.id == id); return(res); }
public void SavePartnersSpec(ps_specs item) { try { db.SavePartnersSpec(item); } catch (Exception ex) { RDL.Debug.LogError(ex); } }
// public ps_specs GetPartnersSpec(int id, string name) { ps_specs res = db.ps_specs.FirstOrDefault(x => x.id == id && x.name == name); return(res); }