public SuppliersView GetSupplierById(int id)
 {
     using (var supplier = new SuppliersRepository())
     {
         Suppliers supp     = supplier.GetById(id);
         var       suppView = new SuppliersView();
         if (supp != null)
         {
             suppView.SupplierId       = supp.SupplierId;
             suppView.EmailAddress     = supp.EmailAddress;
             suppView.Status           = supp.Status;
             suppView.PhysicalAddress  = supp.PhysicalAddress;
             suppView.ShortCode        = supp.ShortCode;
             suppView.SupplierCellNo   = supp.SupplierCellNo;
             suppView.SupplierLastName = supp.SupplierLastName;
             suppView.SupplierName     = supp.SupplierName;
             suppView.UserId           = supp.UserId;
             suppView.SupplierTelNo    = supp.SupplierTelNo;
         }
         return(suppView);
     }
 }
        //owner approval
        public void Approve(SuppliersView model)
        {
            using (var supplier = new SuppliersRepository())
            {
                var supp = supplier.GetById(model.SupplierId);
                if (supp != null)
                {
                    supp.SupplierId       = model.SupplierId;
                    supp.Status           = model.Status;
                    supp.SupplierId       = supp.SupplierId;
                    supp.EmailAddress     = supp.EmailAddress;
                    supp.PhysicalAddress  = supp.PhysicalAddress;
                    supp.ShortCode        = supp.ShortCode;
                    supp.SupplierCellNo   = supp.SupplierCellNo;
                    supp.SupplierLastName = supp.SupplierLastName;
                    supp.SupplierName     = supp.SupplierName;
                    supp.UserId           = supp.UserId;
                    supp.SupplierTelNo    = model.SupplierTelNo;

                    supplier.Update(supp);
                }
            }
        }
Exemplo n.º 3
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var supplier = _suppliersRepository.GetById((int)id);


            if (supplier == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new SuppliersBaseViewModel()
            {
                Supplier = supplier
            };

            viewModel.Init(_suppliersRepository);

            return(View(viewModel));
        }