public void AddNewSupplier(SuppliersView model, string userId) { using (var supplier = new SuppliersRepository()) { var supp = new Suppliers { SupplierId = model.SupplierId, EmailAddress = model.EmailAddress, PhysicalAddress = model.PhysicalAddress, Status = "Waiting For Approval", SupplierCellNo = model.SupplierCellNo, SupplierLastName = model.SupplierLastName, SupplierName = model.SupplierName, SupplierTelNo = model.SupplierTelNo, UserId = userId, ShortCode = "" }; supplier.Insert(supp); //update supp.ShortCode = (Guid.NewGuid().ToString().Substring(0, 4) + "-" + supp.SupplierId + "-" + model.SupplierName.Substring(0, 1) + model.SupplierLastName.Substring(0, 1)).ToUpper(); supplier.Update(supp); } }
//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); } } }