Пример #1
0
        public static AspNetUserDashboard Convert_DTO_Table(UsersDashboardDTO user_dashboard_dto)
        {
            AspNetUserDashboard tbl_AspnetUserDashboard = new AspNetUserDashboard();

            try
            {
                tbl_AspnetUserDashboard = Mapper.Map <UsersDashboardDTO, AspNetUserDashboard>(user_dashboard_dto, tbl_AspnetUserDashboard);
            }
            catch (Exception ex)
            {
                throw;
            }
            return(tbl_AspnetUserDashboard);
        }
Пример #2
0
        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);
        }