示例#1
0
        public Result <CategoryDO> Update(string CacheKey, CategoryDO model)
        {
            Result <CategoryDO> result;

            try
            {
                var updateEntity = _categoryService.Get(w => w.Id == model.Id);
                updateEntity.IsActive         = model.IsActive;
                updateEntity.ParentCategoryId = model.ParentCategoryId;
                updateEntity.UpdateTime       = DateTime.Now;
                updateEntity.CategoryCode     = model.CategoryCode;
                updateEntity.Description      = model.Description;
                updateEntity.DisplayOrder     = model.DisplayOrder;
                updateEntity.CategoryName     = model.CategoryName;

                _categoryService.Update(updateEntity);

                result = new Result <CategoryDO>(model);
            }
            catch (Exception ex)
            {
                result = new Result <CategoryDO>(false, ResultTypeEnum.Error, "An error occured during the updating category operation! Ex:" + ex.ToString());
            }
            return(result);
        }
        private CategoryDO CreateCategory(ProjectDO project, string name)
        {
            var category1 = new CategoryDO
            {
                ProjectId = project.ProjectId,
                Name      = name
            };

            _categoryDao.Create(category1);
            return(category1);
        }
        public void DeleteCategory(CategoryDO category)
        {
            List <TaskDO> tasks = taskDAO.ReadAllByCategoryId(category.CategoryId);

            if (tasks.Any(t => t.Status != TaskStatus.TaskComplete))
            {
                throw new ValidationException("Category contains active tasks!");
            }
            else
            {
                categoryDAO.Delete(category);
            }
        }
示例#4
0
        public ActionResult ContentTable(string typeOfContent)
        {
            if (!typeOfContent.Equals(MenuItem.MESSAGE.ToString()))
            {
                List <CategoryDO> Categories = CategoryDO.GetCategory(typeOfContent);
                ViewBag.Products = ProductDO.GetProducts(Categories);

                return(PartialView("_PartialTableContent"));
            }
            else
            {
                return(PartialView("Contact"));
            }
        }
示例#5
0
        public Result <CategoryDO> GetById(int id)
        {
            Result <CategoryDO> result;

            try
            {
                Category   category   = _categoryService.GetAsQueryable(w => w.Id == id).FirstOrDefault();
                CategoryDO categoryDO = Mapper.Map <Category, CategoryDO>(category);
                result = new Result <CategoryDO>(categoryDO);
            }
            catch (Exception ex)
            {
                result = new Result <CategoryDO>(false, ResultTypeEnum.Error, "An error occured when getting Category ! Ex:", ex.Message);
            }
            return(result);
        }
        private TaskDO CreateTask(CategoryDO category, UserDO user, string taskName, string body)
        {
            var task1 = new TaskDO
            {
                CategoryId   = category.CategoryId,
                UserId       = user.UserId,
                TaskName     = taskName,
                Body         = body,
                Status       = TaskStatus.TaskNotStarted,
                ActualWork   = 0,
                CreationTime = DateTime.Today,
                IsComplete   = false
            };

            _taskDao.Create(task1);
            return(task1);
        }
示例#7
0
        public Result <CategoryDO> Add(string CacheKey, CategoryDO model)
        {
            Result <CategoryDO> result;

            try
            {
                model.CreateTime = DateTime.Now;
                model.UpdateTime = DateTime.Now;
                Category entity = Mapper.Map <CategoryDO, Category>(model);
                _categoryService.Add(entity);
                model.Id = entity.Id;
                result   = new Result <CategoryDO>(true, ResultTypeEnum.Success, model, "Category Was Successfully Saved");
            }
            catch (Exception ex)
            {
                result = new Result <CategoryDO>(false, ResultTypeEnum.Error, $"An Error Occured When Adding Operation Ex : {ex.ToString()}");
            }
            return(result);
        }
        public CategoryDO GetCategoryByID(int Category_ID)
        {
            SqlCommand cmd = new SqlCommand("select * from Category where Category_ID = @Category_ID", conn);

            cmd.Parameters.AddWithValue("Category_ID", Category_ID);
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            DataSet        ds  = new DataSet();

            adp.Fill(ds);

            var query = from cat in ds.Tables[0].AsEnumerable()
                        select new CategoryDO
            {
                Category_ID   = Convert.ToInt32(cat[0]),
                Category_Name = cat[1].ToString(),
                //UpdatedDate = Convert.ToDateTime(cat[2])
            };
            CategoryDO objCategory = query.FirstOrDefault();

            return(objCategory);
        }
示例#9
0
 public CategoryViewModel()
 {
     CategoryDO   = new CategoryDO();
     CategoryList = new List <CategoryDO>();
 }
 public CategoryDO UpdateCategory(CategoryDO category)
 {
     return(categoryDAO.Update(category));
 }
 public CategoryDO CreateCategory(CategoryDO category)
 {
     return(categoryDAO.Create(category));
 }
示例#12
0
        public IActionResult UpdateCategory([FromBody] CategoryDO category)
        {
            Result <CategoryDO> result = _categoryBL.Update(CacheKey, category);

            return(Json(result));
        }
示例#13
0
        public IActionResult InsertCategory([FromBody] CategoryDO category)
        {
            Result <CategoryDO> result = _categoryBL.Add(CacheKey, category);

            return(Json(result));
        }