private SupplierDepartment ApplyChanges(SupplierDepartmentEditModel model) { return(new SupplierDepartment() { SupplierDepartmentID = model.SupplierDepartmentID, Commission = model.Commission, Handling = model.Handling, SupplierDepartmentName = model.SupplierDepartmentName, SupplierID = model.SupplierID, CountryID = model.CountryID, GivesRebate = model.GivesRebate, Rebate = model.RebateAmount, FactorSupplierDepartmentID = model.FactorSupplierDepartmentID, IsTransactionTaxExempt = model.IsTransactionTaxExempt, TransactionTaxReference = model.TransactionTaxReference, CreditTerm = model.CreditTerm, CreditLimit = model.CreditLimit, EmailAddress = model.EmailAddress, //NoteID = model.NoteID, CreatedDate = !string.IsNullOrEmpty(model.CreatedDate) ? DateTime.Parse(model.CreatedDate) : DateTime.Now, CreatedBy = _principal.Id, UpdatedDate = DateTime.Now, UpdatedBy = _principal.Id, IsActive = true, }); }
public SupplierDepartmentEditModel CreateSupplierDepartment(SupplierDepartmentEditModel model, List <Guid> locaGuidList) { try { var depaItem = ApplyChanges(model); depaItem.NoteID = SaveNote(model); if (model.SupplierDepartmentID == Guid.Empty && model.ItemAdding && !model.ItemDeleting) { model.SupplierDepartmentID = PrimeActs.Service.IDGenerator.NewGuid(_serverCode[0]); depaItem.SupplierDepartmentID = model.SupplierDepartmentID; depaItem.ObjectState = ObjectState.Added; _supplierDepartmentService.Insert(depaItem); InsertSupplierDepartmentLocation(depaItem, locaGuidList); } else if (!model.ItemAdding && !model.ItemDeleting) { depaItem.ObjectState = ObjectState.Modified; _supplierDepartmentService.Update(depaItem); //UpdateSupplierDepartmentLocation(depaItem, locaGuidList); //nem } } catch (Exception ex) { throw new ApplicationException("Creating Supplier Department failed", ex); } return(model); }
private Guid UpdateNote(SupplierDepartmentEditModel model, ApplicationUser author) { var note = _noteService.Find(model.NoteID.Value); note.NoteText = model.Notes; note.NoteDescription = model.NoteDescription; note.ObjectState = ObjectState.Modified; _noteService.Update(note); return(note.NoteID); }
private SupplierDepartmentEditModel BuildSupplierDeptEditModelAC(SupplierDepartment sdentity) { SupplierDepartmentEditModel strSupplierDeptList = new SupplierDepartmentEditModel(); strSupplierDeptList.SupplierDepartmentName = sdentity.Supplier.SupplierCode + " - " + sdentity.Supplier.SupplierCompanyName + " - "; strSupplierDeptList.SupplierDepartmentName = strSupplierDeptList.SupplierDepartmentName + sdentity.SupplierDepartmentName + " - " + sdentity.Commission + " - " + sdentity.Handling; strSupplierDeptList.SupplierDepartmentID = sdentity.SupplierDepartmentID; strSupplierDeptList.CountryID = sdentity.CountryID ?? Guid.Parse("00760000-0000-0001-0006-827344180700"); strSupplierDeptList.CountryName = sdentity.Country == null ? "United Kingdom" : sdentity.Country.CountryName; return(strSupplierDeptList); }
private Guid CreateNote(SupplierDepartmentEditModel model, ApplicationUser author) { var note = new Note { NoteID = PrimeActs.Service.IDGenerator.NewGuid(_serverCode[0]), NoteText = model.Notes, NoteDescription = model.NoteDescription, // IsActive = true, ObjectState = ObjectState.Added }; _noteService.Insert(note); return(note.NoteID); }
private Guid?SaveNote(SupplierDepartmentEditModel model) { if (string.IsNullOrEmpty(model.NoteDescription)) { model.NoteDescription = "?!"; // <--- Paul Edwards } if (!string.IsNullOrEmpty(model.Notes)) { if (model.NoteID == null || model.NoteID == Guid.Empty) { model.NoteID = CreateNote(model, _principal); } else { model.NoteID = UpdateNote(model, _principal); } } return(model.NoteID); }
public List <SupplierDepartmentEditModel> BuildSupplierDepartmentModels(List <SupplierDepartment> supplierDepartments) { var list = new List <SupplierDepartmentEditModel>(); foreach (var item in supplierDepartments) { var model = new SupplierDepartmentEditModel(); model.SupplierDepartmentID = item.SupplierDepartmentID; model.SupplierDepartmentName = item.SupplierDepartmentName; model.SupplierID = item.SupplierID; model.EmailAddress = item.EmailAddress; model.Commission = item.Commission.HasValue ? item.Commission.Value : 0; model.Handling = item.Handling.HasValue ? item.Handling.Value : 0; model.GivesRebate = item.GivesRebate; model.RebateAmount = item.Rebate.HasValue ? item.Rebate.Value : 0; model.CountryID = item.CountryID.HasValue ? item.CountryID.Value : Guid.Empty; model.CountryName = item.CountryID.HasValue ? _countryService.CountryById(item.CountryID.Value).CountryName : string.Empty; model.IsTransactionTaxExempt = item.IsTransactionTaxExempt; model.TransactionTaxReference = item.TransactionTaxReference; model.CreditTerm = item.CreditTerm.HasValue ? item.CreditTerm.Value : 0; model.CreditLimit = item.CreditLimit.HasValue ? item.CreditLimit.Value : 0; model.NoteID = item.NoteID; model.Notes = item.NoteID.HasValue ? _noteService.Find(item.NoteID.Value).NoteText : string.Empty; // setup LxbViewModel of ListBox var supplierDepartmentLocations = _supplierDepartmentLocationService.GetSupplierDepartmentLocationListByDepId(item.SupplierDepartmentID); model.SelectedLocationIds = new List <string>(); model.LbxLocationOptions = new List <LbxViewModel>(); foreach (var sdl in supplierDepartmentLocations) { model.SelectedLocationIds.Add(sdl.SupplierLocationID.ToString()); var lxbItem = new LbxViewModel(); lxbItem.Id = sdl.SupplierLocationID.ToString(); lxbItem.label = _supplierLocationService.GetSupplierLocationById(sdl.SupplierLocationID).SupplierLocationName; lxbItem.value = sdl.SupplierLocationID.ToString(); model.LbxLocationOptions.Add(lxbItem); } list.Add(model); } return(list); }