public HomePage_WidgetDTO Update(HomePage_WidgetDTO home_page_widget_dto) { tblHomePage_Widget tbl_home_page_update = Get_Home_Page_By_ID_And_User_ID(home_page_widget_dto.Widget_Id, home_page_widget_dto.User_Id); try { if (tbl_home_page_update != null) { tbl_home_page_update = HomePage_WidgetDTO_Converter.Convert(home_page_widget_dto); _dbcontext.tblHomePage_Widget.Attach(tbl_home_page_update); _dbcontext.Entry(tbl_home_page_update).State = EntityState.Modified; _dbcontext.SaveChanges(); return(home_page_widget_dto); } else { throw new ArgumentNullException("Home Page widget not forund"); } } catch { throw; } }
public int Create_Dashboard(DashboardDTO dashboard, string user_id) { tblDashboard tbl_dashboard = _dbcontext.tblDashboards.Find(dashboard.Id); if (tbl_dashboard == null) { AspNetUserDashboard aspnetuser_dashbaord = new AspNetUserDashboard() { User_Id = user_id }; tbl_dashboard = _dbcontext.tblDashboards.Add(ConvertDashboard.ConvertDashboardDTO_To_Table(dashboard)); tbl_dashboard.AspNetUserDashboards.Add(aspnetuser_dashbaord); } else { tblDashboard tbl_dashboard_new = ConvertDashboard.ConvertDashboardDTO_To_Table(dashboard); _dbcontext.Entry(tbl_dashboard).CurrentValues.SetValues(tbl_dashboard_new); } _dbcontext.SaveChanges(); return(tbl_dashboard.Id); }