private BranchOfficeModel PrepareBranchOfficeModel(BranchOffice office) { Guard.IsNotNull(office, "office"); var model = new BranchOfficeModel() { RowId = office.RowId, Abbreviation = office.Abbreviation, BranchName = office.BranchName, Address = office.Address.ToModel() }; PrepareAuditHistoryModel(model, office); return model; }
public ActionResult Create(BranchOfficeModel model) { if (ModelState.IsValid) { var office = new BranchOffice { BranchName = model.BranchName, Abbreviation = model.Abbreviation, CreatedOn = DateTime.UtcNow, UpdatedOn = DateTime.UtcNow, CurrentPublishingStatus = PublishingStatus.Active // by default the client status is active }; if (!string.IsNullOrEmpty(model.Address.Address1) || !string.IsNullOrEmpty(model.Address.City) || !string.IsNullOrEmpty(model.Address.PhoneNumber) || !string.IsNullOrEmpty(model.Address.FaxNumber) || model.Address.CountryId.HasValue || model.Address.StateProvinceId.HasValue) { office.Address = model.Address.ToEntity(); office.Address.CreatedOn = office.Address.UpdatedOn = DateTime.UtcNow; } // we need to add this client dataService.Insert(office); // return notification message SuccessNotification(localizationService.GetResource("BranchOffice.Added")); return RedirectToAction(SystemRouteNames.Index); } //If we got this far, something failed, redisplay form PrepareAddEditModel(model); return View(model); }
/// <summary> /// Updates the branch office /// </summary> /// <param name="branchOffice">branchOffice</param> public virtual void Update(BranchOffice branchOffice) { Guard.IsNotNull(branchOffice, "branchOffice"); // add audit history branchOffice.AuditHistory.Add ( userActivityService.InsertActivity(SystemActivityLogTypeNames.Update, branchOffice.ToString(), StateKeyManager.BRANCHOFFICE_ACTIVITY_COMMENT, branchOffice.BranchName) ); this.dataRepository.Update(branchOffice); this.cacheManager.RemoveByPattern(BRANCHOFFICE_PATTERN_KEY); //event notification this.eventPublisher.EntityUpdated(branchOffice); }