public void Save()
        {
            //Arrage
            ItemCategory ic = new ItemCategory();

            ic.Name            = "Test";
            ic.Description     = "Tests";
            ic.Status          = new StatusRepository(context).FindById(1);
            ic.CreatedDateTime = DateTime.Now;

            //Act
            var result = itemCategoryService.Save(ic);

            //Assert
            Assert.AreEqual("Test", result.Name);
            itemCategoryRepository.Delete(ic);
        }
        public ActionResult Save(ItemCategoryViewModel model)
        {
            bool status = false;

            statusService       = new StatusService(context);
            itemcategoryService = new ItemCategoryService(context);
            userService         = new UserService(context);

            ItemCategory s = new ItemCategory();

            if (itemcategoryService.FindItemCategoryByItemCategoryId(model.ItemCategoryId) == null)
            {
                //new item category
                s.ItemCategoryId = IdService.GetNewItemCategoryId(context);
                //assign user info
                s.CreatedDateTime = DateTime.Now;
                s.CreatedBy       = userService.FindUserByEmail(CurrentUserName);
            }

            else
            {
                //existing ItemCategory
                s = itemcategoryService.FindItemCategoryByItemCategoryId(model.ItemCategoryId);

                //assign user info into update fields
                s.UpdatedDateTime = DateTime.Now;
                s.UpdatedBy       = userService.FindUserByEmail(CurrentUserName);
            }

            //assign item category info
            s.Name        = model.Name;
            s.Description = model.Description;
            s.Status      = statusService.FindStatusByStatusId(model.Status);

            //save info to database
            if (itemcategoryService.Save(s) != null)
            {
                status = true;
            }

            //return RedirectToAction("Index", "ItemCategory");
            return(new JsonResult {
                Data = new { status = status }
            });
        }