public string Edit(FormDataCollection form) { var retVal = string.Empty; var operation = form.Get("oper"); var id = form.Get("SourceTypeId").ToInt32(); if (!string.IsNullOrEmpty(operation)) { SourceTypeInfo info; switch (operation) { case "edit": info = SourceTypeRepository.GetInfo(id); if (info != null) { info.Code = form.Get("Code"); info.Name = form.Get("Name"); info.ChangedDate = DateTime.Now; info.Description = form.Get("Description"); info.ChangedBy = UserContext.GetCurrentUser().UserID; info.IsCheckUpdate = form.Get("IsCheckUpdate").ToBoolean(); info.IsCheckDuplicate = form.Get("IsCheckDuplicate").ToBoolean(); info.IsShowHotLine = form.Get("IsShowHotLine").ToBoolean(); info.IsShowConsultant = form.Get("IsShowConsultant").ToBoolean(); SourceTypeRepository.Update(info); } break; case "add": info = new SourceTypeInfo { Code = form.Get("Code"), Name = form.Get("Name"), CreatedDate = DateTime.Now, Description = form.Get("Description"), CreatedBy = UserContext.GetCurrentUser().UserID, IsShowHotLine = form.Get("IsShowHotLine").ToBoolean(), IsCheckUpdate = form.Get("IsCheckUpdate").ToBoolean(), IsCheckDuplicate = form.Get("IsCheckDuplicate").ToBoolean(), IsShowConsultant = form.Get("IsShowConsultant").ToBoolean(), }; SourceTypeRepository.Create(info); break; case "del": SourceTypeRepository.Delete(id); break; } } StoreData.ListSourceType = SourceTypeRepository.GetAll() ?? new List<SourceTypeInfo>(); return retVal; }
public static void Update(SourceTypeInfo info) { DataProvider.Instance().SourceTypes_Update(info.SourceTypeId, info.Code, info.Name, info.Description, info.IsCheckDuplicate, info.IsCheckUpdate, info.IsShowHotLine, info.IsShowConsultant, info.CreatedBy, info.CreatedDate, info.ChangedBy, info.ChangedDate); }