public ActionResult Create(int? id)
        {
            var userName = System.Web.HttpContext.Current.User.Identity.Name;
            var user = _systemService.GetUserAndRole(0, userName);
            if (user == null)
            {
                return RedirectToAction("Index", "Login");
            }

            if (user.StockServiceR == 0)
            {
                return RedirectToAction("Index", "Home");
            }

            var item = new WAMS_ITEMS_SERVICE();

            if (id.HasValue)
            {
                item = _service.GetByKey(id.Value);
            }

            var model = new ServiceViewModel
            {
                Id = item.Id,
                vIDServiceItem = item.vIDServiceItem,
                vServiceItemName = item.vServiceItemName,
                bUnitID = item.bUnitID,
                bCategoryID = item.bCategoryID,
                bPositionID = item.bPositionID,
                bWeight = item.bWeight,
                vAccountCode = item.vAccountCode,
                Timestamp = item.Timestamp,
                UserLogin = user,
                Categories = new SelectList(_systemService.CategoryStockList(8), "Id", "Name"),
                Units = new SelectList(_systemService.UnitStockList(8), "Id", "Name"),
                Positions = new SelectList(_systemService.PositionStockList(), "Id", "Name")
            };

            return View(model);
        }
Exemple #2
0
 public bool Update(WAMS_ITEMS_SERVICE stock)
 {
     _repository.Update(stock);
     _unitOfWork.CommitChanges();
     return true;
 }
Exemple #3
0
 public bool Insert(WAMS_ITEMS_SERVICE stock)
 {
     _repository.Add(stock);
     _unitOfWork.CommitChanges();
     return true;
 }
        private JsonResult CreateData(ServiceViewModel model)
        {
            if (_service.ExistedName(model.vServiceItemName))
            {
                return Json(new { result = Constants.Duplicate });
            }

            try
            {
                var item = new WAMS_ITEMS_SERVICE
                    {
                        vIDServiceItem = model.vIDServiceItem,
                        vServiceItemName = model.vServiceItemName,
                        vDescription = model.vDescription,
                        bCategoryID = model.bCategoryID,
                        bUnitID = model.bUnitID,
                        bPositionID = model.bPositionID,

                        // bSupplierID = viewModel.bSupplierID,
                        vStockType = "Service",
                        iEnable = true,
                        bWeight = model.bWeight,
                        vAccountCode = model.vAccountCode,
                        dCreated = DateTime.Now,
                        StoreId = model.StoreId
                    };

                _service.Insert(item);

                return Json(new { result = Constants.Success });
            }
            catch (Exception e)
            {
                Log.Error("Create New Service!", e);
                return Json(new { result = Constants.UnSuccess });
            }
        }