コード例 #1
0
        public async Task <IActionResult> New([Bind(Prefix = "Item1")] EF.Category model, [Bind(Prefix = "Item2")] bool isactive)
        {
            ViewData["Title"] = "Category/New";

            try
            {
                model.CreatedBy = User.Identity.Name;

                if (!isactive)
                {
                    model.DateInactive = DateTime.Now;
                }

                await new BLL.Category(unitOfWork).Add(model);
                return(Redirect("~/Main/Category"));
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError(string.Empty, "Entry is causing conflict to other records.");
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
            }

            ViewBag.BlogSortOrders = (await new BLL.BlogSortOrder(unitOfWork).Find(new EF.BlogSortOrder())).ToList();

            var obj = new Tuple <EF.Category, bool>(model, isactive);

            return(View(obj));
        }
コード例 #2
0
ファイル: AdminCategoryDAO.cs プロジェクト: phuhoang09/KPI
        public bool Add(EF.Category entity)
        {
            entity.Code = entity.Code.ToUpper();

            try
            {
                _dbContext.Categories.Add(entity);
                _dbContext.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                var message = ex.Message;
                return(false);
            }
        }
コード例 #3
0
ファイル: AdminCategoryDAO.cs プロジェクト: phuhoang09/KPI
 public bool Update(EF.Category entity)
 {
     entity.Code = entity.Code.ToUpper();
     try
     {
         var iteam = _dbContext.Categories.FirstOrDefault(x => x.ID == entity.ID);
         iteam.Name    = entity.Name;
         iteam.Code    = entity.Code;
         iteam.LevelID = entity.LevelID;
         _dbContext.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         var message = ex.Message;
         //logging
         return(false);
     }
 }
コード例 #4
0
 public async Task <IActionResult> Index(EF.Category args)
 {
     ViewData["Title"] = "Categories";
     ViewBag.Data      = await new BLL.Category(unitOfWork).Find(args);
     return(View());
 }