Example #1
0
        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.SupplierR ==0)
            {
                return RedirectToAction("Index", "Home");
            }

            var item = new WAMS_SUPPLIER();

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

            var model = new SupplierViewModel
            {
                Id = item.bSupplierID,
                vSupplierName = item.vSupplierName,
                vAddress = item.vAddress,
                vCity = item.vCity,
                Telephone1 = item.vPhone1,
                Telephone2 = item.vPhone2,
                Mobile = item.vMobile,
                vFax = item.vFax,
                Email = item.vEmail,
                vContactPerson = item.vContactPerson,
                fTotalMoney = item.fTotalMoney,
                bSupplierTypeID = item.bSupplierTypeID,
                iEnable = item.iEnable,
                iService = item.iService,
                dDateCreate = item.dDateCreate,
                CountryId = item.CountryId,
                iMarket = item.iMarket,
                iStore = item.iStore,
                iPayment = item.iPayment,
                dCreated = item.dCreated,
                dModified = item.dModified,
                iCreated = item.iCreated,
                iModified = item.iModified,
                Timestamp = item.Timestamp,
                Stores = new SelectList(_systemService.StoreList(), "Id", "Name"),
                Types = new SelectList(_systemService.SupplierTypeList(), "Id", "Name"),
                Countries = new SelectList(_systemService.CountryList(), "Id", "Name"),
                UserLogin = user
            };

            if (!id.HasValue) return View(model);
            var temp = _service.ListConditionDetail(id.Value, "1");
            model.GetProductDetails = temp;
            model.TotalRecords = temp.Count;

            // FUNCTION
            return View(model);
        }
Example #2
0
 public bool Insert(WAMS_SUPPLIER entity, List<WAMS_PRODUCT> entityDetails)
 {
     _repository.Add(entity);
     _unitOfWork.CommitChanges();
     if (entityDetails != null)
     {
         foreach (var detail in entityDetails)
         {
             var detailEntity = new WAMS_PRODUCT
             {
                 vProductID = detail.vProductID,
                 bSupplierID = entity.bSupplierID,
                 vDescription = detail.vDescription,
                 iEnable = true,
                 dCreated = entity.dCreated,
                 iCreated = entity.iCreated
             };
             _repositoryDetail.Add(detailEntity);
         }
     }
     _unitOfWork.CommitChanges();
     return true;
 }
Example #3
0
        public bool Update(WAMS_SUPPLIER entity, List<WAMS_PRODUCT> entityDetails, string LstDeleteDetailItem)
        {
            _repository.Update(entity);
            if (entityDetails != null)
            {
                foreach (var detail in entityDetails)
                {
                    if (detail.Id != 0)
                    {
                        var detailEntity = _repositoryDetail.GetByKey(detail.Id);
                        detailEntity.bSupplierID = entity.bSupplierID;
                        detailEntity.vProductID = detail.vProductID;
                        detailEntity.vDescription = detail.vDescription;
                        detailEntity.dModified = DateTime.Now;
                        detailEntity.iModified = entity.iModified;
                        _repositoryDetail.Update(detailEntity);
                    }
                    else
                    {
                        var detailEntity = new WAMS_PRODUCT
                        {
                            bSupplierID = entity.bSupplierID,
                            vProductID = detail.vProductID,
                            vDescription = detail.vDescription,
                            iEnable = true,
                            dCreated = entity.dCreated,
                            iCreated = entity.iCreated
                        };
                        _repositoryDetail.Add(detailEntity);
                    }
                }

                if (!string.IsNullOrEmpty(LstDeleteDetailItem))
                {
                    var listStrLineElements = LstDeleteDetailItem.Split(';').ToList();
                    foreach (var itemDetail in listStrLineElements)
                    {
                        _customRepository.DeleteDetail(Convert.ToInt32(itemDetail));
                    }
                }
            }
            _unitOfWork.CommitChanges();
            return true;
        }