public ActionResult Edit(ExtendCreateDTO req) { Response res = new Response(); if (ModelState.IsValid) { try { if (req.Id > 0) { res.Data = ExtendRepository.Update(req); } else { res.Data = ExtendRepository.Create(req); } } catch (Exception ex) { res.Message = ex.InnerException.Message; } } else { res.Data = false; res.Message = string.Join(",", ModelState.SelectMany(ms => ms.Value.Errors).Select(e => e.ErrorMessage)); } return(Json(res, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(ExtendCreateDTO req) { Response res = new Response(); if (ModelState.IsValid) { try { if (req.Id > 0) { res.Data = _extendRepository.Update(req); } else { var currentUser = OperatorProvider.Provider.GetCurrent(); req.R_Company_Id = currentUser.CompanyId.ToInt(); res.Data = _extendRepository.Create(req); } } catch (Exception ex) { res.Message = ex.Message; } } else { res.Data = false; res.Message = string.Join(",", ModelState .SelectMany(ms => ms.Value.Errors) .Select(e => e.ErrorMessage)); } return(Json(res, JsonRequestBehavior.AllowGet)); }
public bool Create(ExtendCreateDTO req) { using (var db = new SqlSugarClient(Connection)) { bool result = true; R_ProjectExtend model = new R_ProjectExtend() { Name = req.Name, Description = req.Description, CyxmKzType = req.CyxmKzType, Price = req.Price, Unit = req.Unit, R_ProjectExtendType_Id = req.ExtendType, R_Company_Id = req.R_Company_Id }; if (db.Insert(model) == null) { result = false; } return(result); } }
public bool Update(ExtendCreateDTO req) { using (var db = new SqlSugarClient(Connection)) { bool result = true; R_ProjectExtend model = new R_ProjectExtend() { Name = req.Name, Description = req.Description, Id = req.Id, CyxmKzType = req.CyxmKzType, Price = req.Price, Unit = req.Unit, R_ProjectExtendType_Id = req.ExtendType }; result = db.Update(model); return(result); } }
public ExtendCreateDTO GetModel(int id) { using (var db = new SqlSugarClient(Connection)) { ExtendCreateDTO model = null; var data = db.Queryable <R_ProjectExtend>().InSingle(id); if (data != null) { model = new ExtendCreateDTO() { Id = data.Id, CyxmKzType = data.CyxmKzType, Description = data.Description, Name = data.Name, Price = data.Price, Unit = data.Unit, ExtendType = data.R_ProjectExtendType_Id }; } return(model); } }