public int SavePartnerStatus(ps_statuses element) { try { if (element.id == 0) { db.ps_statuses.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_statuses GetPartnersStatus(int id) { var res = new ps_statuses(); res = db.GetPartnersStatus(id); return(res); }
public ps_statuses GetPartnersStatus(int id) { var res = new ps_statuses(); res = db.ps_statuses.FirstOrDefault(partner => partner.id == id); return(res); }
public void SavePartnerStatus(ps_statuses item) { try { db.SavePartnerStatus(item); } catch (Exception ex) { RDL.Debug.LogError(ex); } }
public ActionResult PartnersStatuses_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 newPartnerStatus = new ps_statuses { id = (AjaxModel.GetValueFromSaveField("id", fields) == "") ? 0 : int.Parse(AjaxModel.GetValueFromSaveField("id", fields)), name = (AjaxModel.GetValueFromSaveField("name".Trim(), fields)), code = (AjaxModel.GetValueFromSaveField("code".Trim(), fields)), color = (AjaxModel.GetValueFromSaveField("color".Trim(), fields)), order = (AjaxModel.GetValueFromSaveField("order".Trim(), fields)) }; mng.SavePartnerStatus(newPartnerStatus); return(Json(new { result = true, id = newPartnerStatus.id, mng = "Операция прошла успешно" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { RDL.Debug.LogError(ex); return(Json(new { result = false, id = 0, mng = "Ошибка" }, JsonRequestBehavior.AllowGet)); } }