public ActionResult UpdateBuilding(Building building) { if (building == null) { TempData["StatusMessage"] = "There was a problem with your request"; return(CurrentUmbracoPage()); } building.ModifiedBy = Members.GetCurrentMember().Id; building.ModifiedOn = DateTime.Now; _buildingRepo.Update(building.Id, building); //updating existing addresses int addressCount = Int32.Parse(Request.Form["AddressCount"]); for (int i = 1; i < addressCount; i++) { int id = Int32.Parse(Request.Form["Address" + i.ToString()]); UpdateAddress(id, i, building.Id); } //adding new addresses SaveNewAddresses(building.Id); return(RedirectToCurrentUmbracoPage()); }
public Address PostSave(Address address) { if (address.Id > 0) { //DatabaseContext.Database.Update(address);. _addressRepo.Update(address.Id, address); return(address); } else { return(_addressRepo.Insert(address)); // DatabaseContext.Database.Save(address); } }
private List <Apartment> MapData(DataTable table, int id = -1) { var list = new List <Apartment>(table.Rows.Count - 1); foreach (DataRow row in table.AsEnumerable()) { var values = row.ItemArray; var existingApt = _apartmentRepo .GetAll() .FirstOrDefault(a => a.Name.Equals(values[0].ToString(), StringComparison.OrdinalIgnoreCase) && a.BuildingId == id); if (existingApt != null) { existingApt.Name = values[0].ToString(); existingApt.StatusId = GetStatus(values[1].ToString()) != null?GetStatus(values[1].ToString()).Id : -1; existingApt.Size = values[2].ToString(); existingApt.NumberOfRooms = int.Parse(values[3].ToString()); existingApt.Price = decimal.Parse(values[4].ToString()); existingApt.BuildingId = id; var isUpdatedApt = _apartmentRepo.Update(existingApt.Id, existingApt); if (isUpdatedApt) { list.Add(existingApt); } continue; } else { var apartment = new Apartment(); apartment.Name = values[0].ToString(); apartment.StatusId = GetStatus(values[1].ToString()) != null?GetStatus(values[1].ToString()).Id : -1; apartment.Size = values[2].ToString(); apartment.NumberOfRooms = int.Parse(values[3].ToString()); apartment.Price = decimal.Parse(values[4].ToString()); apartment.BuildingId = id; var newApartment = _apartmentRepo.Insert(apartment); if (newApartment != null) { list.Add(newApartment); } continue; } } return(list); }
public BuildingBackOfficeModel PostSave(BuildingBackOfficeModel model) { var building = model.Building; var addresses = model.Addresses; umbraco.BusinessLogic.User siteAdmin = umbraco.helper.GetCurrentUmbracoUser(); if (building.Id > 0) { building.ModifiedBy = siteAdmin.Id; building.ModifiedOn = DateTime.Now; _bldgRepo.Update(building.Id, building); } else { building.CreatedBy = siteAdmin.Id; building.CreatedOn = DateTime.Now; building.ModifiedBy = siteAdmin.Id; //should be nullable BM-21 fix building.ModifiedOn = DateTime.Now; //should be nullable BM-21 fix var buildingInserted = _bldgRepo.Insert(building); building.Id = buildingInserted.Id; } foreach (var address in addresses) { if (address.Id > 0) { //DatabaseContext.Database.Update(address); _addressRepo.Update(address.Id, address); } else { if (!IsCanceledAddress(address)) { address.BuildingId = building.Id; //DatabaseContext.Database.Save(address); _addressRepo.Insert(address); } } } return(model); }
public void UpdateAsset(int buildingId, int mediaId) { //check if child media node already exists in the db var dbassetExisting = _buildingAssetRepo.GetById(mediaId); if (dbassetExisting != null) { dbassetExisting.BuildingId = buildingId; dbassetExisting.MediaId = mediaId; dbassetExisting.TypeId = (int)AssetMediaType.Image; //just update to make sure it's referenced to correct buildign and media _buildingAssetRepo.Update(dbassetExisting.Id, dbassetExisting); } else { //re-add each media to db asset table _buildingAssetRepo.Insert((BuildingAsset)AssetFactory.CreateAsset(AssetType.Building, buildingId, mediaId, AssetMediaType.Image)); } }
public ActionResult UpdateAccount(Account account) { _accountRepo.Update(account.Id, account); return(CurrentUmbracoPage()); }
private object UpdateBuildingFolder(int folderId, BuildingFolder folder) { return(_buildingFolderRepo.Update(folderId, folder)); }
private object UpdateApartmentFolder(int folderId, ApartmentFolder folder) { return(_apartmentFolderRepo.Update(folderId, folder)); }
private object UpdateAccountFolder(int folderId, AccountFolder folder) { return(_accountFolderRepo.Update(folderId, folder)); }