// Update a param public bool Update(TM_MeasureParam entity) { try { var param = db.TM_MeasureParam.Find(entity.Id); if (!string.IsNullOrEmpty(entity.CodeName)) { param.CodeName = entity.CodeName; } if (entity.Type != null) { param.Type = entity.Type; } if (!string.IsNullOrEmpty(entity.Unit)) { param.Unit = entity.Unit; } if (!string.IsNullOrEmpty(entity.Description)) { param.Description = entity.Description; } if (entity.Status != null) { param.Status = entity.Status; } db.SaveChanges(); return(true); } catch (Exception) { //logging return(false); } }
// Create a new param public int Create(TM_MeasureParam entity) { entity.CreatedDate = DateTime.Now; db.TM_MeasureParam.Add(entity); db.SaveChanges(); return(entity.Id); }
public JsonResult Create(MeasureParamDetail param) { TM_MeasureParam entity = new TM_MeasureParam(); entity.CreatedDate = DateTime.Now; entity.CodeName = param.CodeName; entity.Description = param.Description; entity.Status = param.Status; entity.Unit = param.Unit; entity.Type = param.Type; int result = new MeasureParamDao().Create(entity); param.Id = entity.Id; param.TypeName = new ParamTypeDao().FindName(param.Type); if (result > 0) { return(Json(param)); } else { return(NotifyError("Thêm")); } }
public JsonResult Update([Bind(Include = "Id,CodeName,Description,Type,Unit,Status")] TM_MeasureParam param) { bool result = new MeasureParamDao().Update(param); string TypeName = new ParamTypeDao().FindName(param.Type); if (result) { return(Json(new { isNewRecord = false, Id = param.Id, CodeName = param.CodeName, Description = param.Description, Unit = param.Unit, Status = param.Status, Type = param.Type, TypeName = TypeName })); } else { return(NotifyError("Sửa")); } }