public ActionResult MainCategories(int?Page)
        {
            MainCategoryModel model = new MainCategoryModel();

            model.PageNumber = (Page == null ? 1 : Convert.ToInt32(Page));
            int currentpage                         = model.PageNumber;
            int pageSize                            = Common.pagesize;
            int TotalRowCount                       = 0;
            List <MainCategoryModel> lst            = dal.SelectAllDataForBindGrid(currentpage, pageSize, out TotalRowCount);
            List <MainCategoryModel> lstcheckdelete = new List <MainCategoryModel>();

            foreach (var m in lst)
            {
                bool enable = dal.CheckDelete(m.ID);
                m.IsDelete = enable;
                lstcheckdelete.Add(m);
            }
            model.MainCategories = lstcheckdelete;

            if (lst.Count > 0)
            {
                List <ListItem> lstPager = Common.generatePager(TotalRowCount, pageSize, currentpage);
                model.dlPager = lstPager;
            }
            return(View(model));
        }
示例#2
0
 public ActionResult EditMainCategory(MainCategoryModel model)
 {
     if (ModelState.IsValid)
     {
         this.mainCategoryRepository.Update(model);
         return(this.RedirectToIndex());
     }
     return(View(model));
 }
示例#3
0
        public ActionResult DeleteMainCategory(MainCategoryModel model)
        {
            var result = this.mainCategoryRepository.Delete(model.Id);

            if (result.IsValid)
            {
                return(this.RedirectToIndex());
            }
            return(View(model));
        }
示例#4
0
        public ActionResult Index()
        {
            MainCategoryModel model = new MainCategoryModel();

            Array enumCategories = Enum.GetValues(typeof(DrinkCategory));

            for (int i = 0; i < enumCategories.Length; i++)
                model.Add(new MainCategory { ID = i, Name = enumCategories.GetValue(i).ToString() });

            return View(model);
        }
示例#5
0
        public MainPageModel PrepareMainPageModel(List <Category> categories)
        {
            if (categories == null)
            {
                throw new ArgumentNullException(nameof(categories));
            }

            var model = new MainPageModel();

            foreach (var category in categories)
            {
                var catModel = new MainCategoryModel
                {
                    Name   = category.Name,
                    SeName = _urlRecordService.GetSeName(category),
                    Id     = category.Id
                };
                var newses    = _newsService.GetAllNews(categoryId: category.Id, showHidden: true, approved: true);
                var newsModel = newses.Select(x => new NewsPopulerModel
                {
                    SeName     = _urlRecordService.GetSeName(x),
                    Title      = x.Title,
                    Id         = x.Id,
                    PictureUrl = _pictureService.GetPictureUrl(x.PictureId),
                    Short      = x.Short.Chop("20")
                }).ToList();
                var bigNewses    = _newsService.GetAllNews(categoryId: category.Id, showHidden: true, approved: true).Where(x => x.BigNews);
                var bigNewsModel = bigNewses.Select(x => new NewsPopulerModel
                {
                    SeName     = _urlRecordService.GetSeName(x),
                    Title      = x.Title,
                    Id         = x.Id,
                    PictureUrl = _pictureService.GetPictureUrl(x.PictureId),
                    Short      = x.Short.Chop("20")
                }).ToList();
                catModel.NewsModels    = newsModel;
                catModel.NewsBigModels = bigNewsModel;
                model.MainCategoryModel.Add(catModel);
            }
            return(model);
        }
示例#6
0
        public bool SaveNewMainCategory(string data)
        {
            bool status = false;

            try
            {
                _dataContext = new LONDataClassesDataContext();
                var dbObject     = new MainCategoryMaster();
                var mainCategory = new MainCategoryModel();

                serialize    = new JavaScriptSerializer();
                mainCategory = serialize.Deserialize <MainCategoryModel>(data);

                mainCategory.CreatedDate  = DateTime.Now;
                mainCategory.ModifiedDate = DateTime.Now;
                mainCategory.ModifiedBy   = "tempModifiedName";

                //Id is auto increamented. No need to pass value.
                ////  dbObject.MainCategoryId = 1;
                dbObject.MainCategoryName  = mainCategory.CategoryName;
                dbObject.MainCategoryImage = mainCategory.ImagePath;
                dbObject.CreatedBy         = mainCategory.CreatedBy;
                dbObject.CreatedDate       = mainCategory.CreatedDate;
                dbObject.ModifiedDate      = mainCategory.ModifiedDate;
                dbObject.ModifiedBy        = mainCategory.ModifiedBy;

                _dataContext.MainCategoryMasters.InsertOnSubmit(dbObject);
                _dataContext.SubmitChanges();

                status = true;
            }
            catch (Exception exp)
            {
                status = false;
            }
            return(status);
        }
 public MainPage()
 {
     model = new MainCategoryModel();
     this.InitializeComponent();
 }
 public IActionResult Create()
 {
     Category = new MainCategoryModel();
     return(View(Category));
 }