public override DTO.MaterialColorMng.EditFormData GetData(int id, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; DTO.MaterialColorMng.EditFormData data = new DTO.MaterialColorMng.EditFormData(); data.Data = new DTO.MaterialColorMng.MaterialColor(); //try to get data try { using (MaterialColorMngEntities context = CreateContext()) { data.Data = converter.DB2DTO_MaterialColor(context.MaterialColorMng_MaterialColor_View.FirstOrDefault(o => o.MaterialColorID == id)); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
public override bool DeleteData(int id, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; try { using (MaterialColorMngEntities context = CreateContext()) { MaterialColor dbItem = context.MaterialColor.FirstOrDefault(o => o.MaterialColorID == id); if (dbItem == null) { notification.Message = "MaterialColor not found!"; return(false); } else { context.MaterialColor.Remove(dbItem); context.SaveChanges(); return(true); } } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; return(false); } }
public override DTO.MaterialColorMng.SearchFormData GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; DTO.MaterialColorMng.SearchFormData data = new DTO.MaterialColorMng.SearchFormData(); data.Data = new List <DTO.MaterialColorMng.MaterialColorSearchResult>(); totalRows = 0; string MaterialColorUD = null; string MaterialColorNM = null; if (filters.ContainsKey("MaterialColorUD") && !string.IsNullOrEmpty(filters["MaterialColorUD"].ToString())) { MaterialColorUD = filters["MaterialColorUD"].ToString().Replace("'", "''"); } if (filters.ContainsKey("MaterialColorNM") && !string.IsNullOrEmpty(filters["MaterialColorNM"].ToString())) { MaterialColorNM = filters["MaterialColorNM"].ToString().Replace("'", "''"); } //try to get data try { using (MaterialColorMngEntities context = CreateContext()) { totalRows = context.MaterialColorMng_function_SearchMaterialColor(MaterialColorUD, MaterialColorNM, orderBy, orderDirection).Count(); var result = context.MaterialColorMng_function_SearchMaterialColor(MaterialColorUD, MaterialColorNM, orderBy, orderDirection); data.Data = converter.DB2DTO_MaterialColorSearchResultList(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }