public void TestMethodHomePage_Widget_Table_DTO()
        {
            tblHomePage_Widget tbl_home_page_widget = new tblHomePage_Widget();

            tbl_home_page_widget.Widget_Id     = 21;
            tbl_home_page_widget.User_Id       = "65465sd4fsdfsdfsd";
            tbl_home_page_widget.widget_x      = 0;
            tbl_home_page_widget.widget_y      = 1;
            tbl_home_page_widget.widget_width  = 10;
            tbl_home_page_widget.widget_height = 20;

            HomePage_WidgetDTO dto = HomePage_WidgetDTO_Converter.Convert(tbl_home_page_widget);

            Assert.IsNotNull(dto);

            tbl_home_page_widget = HomePage_WidgetDTO_Converter.Convert(dto);

            Assert.IsNotNull(tbl_home_page_widget);


            IList <tblHomePage_Widget> list_tbl_home_page = new List <tblHomePage_Widget>();

            list_tbl_home_page.Add(tbl_home_page_widget);
            list_tbl_home_page.Add(tbl_home_page_widget);
            list_tbl_home_page.Add(tbl_home_page_widget);
            list_tbl_home_page.Add(tbl_home_page_widget);
            list_tbl_home_page.Add(tbl_home_page_widget);


            IList <HomePage_WidgetDTO> listdto = HomePage_WidgetDTO_Converter.Convert(list_tbl_home_page);

            Assert.IsNotNull(listdto);

            Assert.AreEqual(listdto.Count, 5);
        }
        private static Mock <DbSet <tblHomePage_Widget> > GetQueryableMockDocumentDbSet()
        {
            tblHomePage_Widget tbl_home_page_widget = new tblHomePage_Widget();

            tbl_home_page_widget.Widget_Id     = 21;
            tbl_home_page_widget.User_Id       = "65465sd4fsdfsdfsd";
            tbl_home_page_widget.widget_x      = 0;
            tbl_home_page_widget.widget_y      = 1;
            tbl_home_page_widget.widget_width  = 10;
            tbl_home_page_widget.widget_height = 20;

            List <tblHomePage_Widget> list_tbl_home_page = new List <tblHomePage_Widget>();

            list_tbl_home_page.Add(tbl_home_page_widget);


            var data = list_tbl_home_page;
            var mockDocumentDbSet = new Mock <DbSet <tblHomePage_Widget> >();

            mockDocumentDbSet.As <IQueryable <tblHomePage_Widget> >().Setup(m => m.Provider).Returns(data.AsQueryable().Provider);
            mockDocumentDbSet.As <IQueryable <tblHomePage_Widget> >().Setup(m => m.Expression).Returns(data.AsQueryable().Expression);
            mockDocumentDbSet.As <IQueryable <tblHomePage_Widget> >().Setup(m => m.ElementType).Returns(data.AsQueryable().ElementType);
            mockDocumentDbSet.As <IQueryable <tblHomePage_Widget> >().Setup(m => m.GetEnumerator()).Returns(data.AsQueryable().GetEnumerator());

            mockDocumentDbSet.Setup(d => d.Add(It.IsAny <tblHomePage_Widget>())).Callback <tblHomePage_Widget>((s) => data.Add(s));

            return(mockDocumentDbSet);
        }
        /// <summary>
        /// Remove widget from home page
        /// </summary>
        /// <param name="home_page_widget_dto"></param>
        public bool Widget_UnPin_To_HomePage(int widget_id, string user_id)
        {
            tblHomePage_Widget tbl_homepage_widget = Get_Home_Page_By_ID_And_User_ID(widget_id, user_id);

            _dbcontext.tblHomePage_Widget.Remove(tbl_homepage_widget);
            _dbcontext.SaveChanges();
            return(true);
        }
Ejemplo n.º 4
0
        public static tblHomePage_Widget Convert(HomePage_WidgetDTO homepage_widget_dto)
        {
            tblHomePage_Widget tbl_homepage_widget = new tblHomePage_Widget();
            try
            {
                tbl_homepage_widget = Mapper.Map<HomePage_WidgetDTO, tblHomePage_Widget>(homepage_widget_dto, tbl_homepage_widget);
            }
            catch (Exception ex)
            {

            }
            return tbl_homepage_widget;
        }
Ejemplo n.º 5
0
        public static HomePage_WidgetDTO Convert(tblHomePage_Widget tbl_homepage_widget)
        {
            HomePage_WidgetDTO homepage_widget_dto = new HomePage_WidgetDTO();
            try
            {
                homepage_widget_dto = Mapper.Map<tblHomePage_Widget, HomePage_WidgetDTO>(tbl_homepage_widget, homepage_widget_dto);
            }
            catch(Exception ex)
            {

            }
            return homepage_widget_dto;
        }
 /// <summary>
 /// Add Widget to homepage
 /// </summary>
 /// <param name="home_page_widget_dto"></param>
 public bool Widget_Pin_To_HomePage(int widget_id, string user_id)
 {
     if (Get_Home_Page_By_ID_And_User_ID(widget_id, user_id) == null)
     {
         try
         {
             tblHomePage_Widget tbl_homepage_widget = HomePage_WidgetDTO_Converter.Convert(Get_Dashboard_Widget_By_Widget_ID_For_Home_Page(widget_id));
             tbl_homepage_widget.User_Id = user_id;
             _dbcontext.tblHomePage_Widget.Add(tbl_homepage_widget);
             _dbcontext.SaveChanges();
             return(true);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
     else
     {
         throw new Exception(Resources.widget_all_ready_added);
     }
 }
        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 HomePage_WidgetDTO Get_Widget_For_Home_Page(int widget_id, string user_id)
        {
            tblHomePage_Widget tbl_homepage_widget = _dbcontext.tblHomePage_Widget.SingleOrDefault(homepage => homepage.Widget_Id == widget_id && homepage.User_Id == user_id);

            return(HomePage_WidgetDTO_Converter.Convert(tbl_homepage_widget));
        }