public ActionResult Edit(int id, PropertyEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.PropertyId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreatePropertyService(); if (service.UpdateProperty(model)) { TempData["SaveResult"] = "The property was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "The property could not be updated."); return(View(model)); }
public ActionResult Edit(int id) { var service = CreatePropertyService(); var detail = service.GetPropertyById(id); var model = new PropertyEdit { PropertyId = detail.PropertyId, Address = detail.Address, City = detail.City, State = detail.State, ZipCode = detail.ZipCode, PurchasePrice = detail.PurchasePrice, YearBuilt = detail.YearBuilt, SqFt = detail.SqFt, HomeTypes = detail.HomeTypes, ArchitecturalStyle = detail.ArchitecturalStyle, Construction = detail.Construction, RoofType = detail.RoofType, FoundationType = detail.FoundationType, NewConstruction = detail.NewConstruction, HistroicRegister = detail.HistroicRegister, NumberOfLevels = detail.NumberOfLevels, AttachedGarage = detail.AttachedGarage, GarageSpaces = detail.GarageSpaces, NumberOfFireplaces = detail.NumberOfFireplaces, NumberOfBathrooms = detail.NumberOfBathrooms, NumberOfFullBaths = detail.NumberOfFullBaths, NumberOfHaftBaths = detail.NumberOfHaftBaths, NumberOfBedrooms = detail.NumberOfBedrooms }; return(View(model)); }
public void UpdatePropertyEdit(PropertyEdit p) { if (p == null) { throw new ArgumentNullException("property is null"); } _propertyEditRepository.Update(p); _eventPublisher.EntityUpdated(p); }
public void DeletePropertyEdit(PropertyEdit p) { if (p == null) { throw new ArgumentNullException("property is null"); } p.Deleted = true; UpdatePropertyEdit(p); }
public ActionResult Edit(PropertyEdit model) { var service = EstablishPropertyService(); if (service.UpdateProperty(model)) { return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your note could not be updated."); return(View(model)); }
public IHttpActionResult Put(PropertyEdit property) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreatePropertyService(); if (!service.UpdateProperty(property)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateProperty(PropertyEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Properties.Single(e => e.PropertyID == model.PropertyID && e.UserID == _userId); entity.Address = model.Address; entity.Size = model.Size; entity.Price = model.Price; entity.Seller = model.Seller; entity.TimeOnMarket = model.TimeOnMarket; entity.PropertyType = model.PropertyType; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id) { var service = CreatePropertyService(); var detail = service.GetPropertyById(id); var model = new PropertyEdit { PropertyID = detail.PropertyID, PropertyOwnerFirstName = detail.PropertyOwnerFirstName, PropertyOwnerLastName = detail.PropertyOwnerLastName, PropertyAddress = detail.PropertyAddress, PropertyPhone = detail.PropertyPhone, PropertyOwnerEmail = detail.PropertyOwnerEmail }; return(View(model)); }
public ActionResult Edit(int id) { var service = CreatePropertyService(); var detail = service.GetPropertyByID(id); var model = new PropertyEdit { PropertyID = detail.PropertyID, Address = detail.Address, Size = detail.Size, Price = detail.Price, Seller = detail.Seller, TimeOnMarket = detail.TimeOnMarket, PropertyType = detail.PropertyType }; return(View(model)); }
//Property Edit: GetBY{ID} and PUT public ActionResult Edit(int id) { var service = EstablishPropertyService(); var detail = service.GetPropertyById(id); var model = new PropertyEdit { PropertyID = detail.PropertyID, Bedroom = detail.Bedroom, Bath = detail.Bath, ListedPrice = detail.ListedPrice, SquareFeet = detail.SquareFeet, AvailableNow = detail.AvailableNow }; return(View(model)); }
public bool UpdateProperty(PropertyEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Property .Single(e => e.PropertyID == model.PropertyID); entity.PropertyOwnerFirstName = model.PropertyOwnerFirstName; entity.PropertyOwnerLastName = model.PropertyOwnerLastName; entity.PropertyAddress = model.PropertyAddress; entity.PropertyPhone = model.PropertyPhone; entity.PropertyOwnerEmail = model.PropertyOwnerEmail; return(ctx.SaveChanges() == 1); } }
public bool UpdateProperty(PropertyEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Prop //.SingleOrDefault(e => e.PropertyID == model.PropertyID && e.UserId==_userId.ToString()); .SingleOrDefault(e => e.PropertyID == model.PropertyID); entity.Bedroom = model.Bedroom; entity.Bath = model.Bath; entity.ListedPrice = model.ListedPrice; entity.SquareFeet = model.SquareFeet; entity.AvailableNow = model.AvailableNow; return(ctx.SaveChanges() == 1); } }
//UPDATE PROPERTY public bool UpdateProperty(PropertyEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Properties .Single(e => e.PropertyId == model.PropertyId && e.OwnerId == model.OwnerId); entity.Title = model.Title; entity.Address = model.Address; entity.NumOfBeds = model.NumOfBeds; entity.Desc = model.Desc; entity.WeekdayRate = model.WeekDayRate; entity.WeekendRate = model.WeekendRate; entity.Rating = model.Rating; entity.PropertyLocation = model.PropertyLocation; return(ctx.SaveChanges() == 1); } }
public static PropertyEdit ToEntity(this PropertyEditModel createmodel, PropertyEdit destination) { return(createmodel.MapTo(destination)); }
public static bool WriteNuSpec( this TaskBase task, string nuSpecFilePath, string editMode = "Replace", ITaskItem[] nuSpecPropValues = null, string nuSpecProperty = null, string nuSpecValue = null, string nuSpecSection = "metadata", bool failIfEmpty = true) { Dictionary <string, PropertyEdit> propValues = new Dictionary <string, PropertyEdit>(); if (nuSpecPropValues != null && (nuSpecProperty != null || nuSpecValue != null)) { task.LogError( "Invalid parameters. Parameter NuSpecPropValues is mutually exclusive with (NuSpecProperty and NuSpecValue). Only use one of the two solutions."); return(false); } if (nuSpecPropValues != null) { if (nuSpecPropValues.Any(nspv => string.IsNullOrWhiteSpace(nspv.GetMetadata("Property")) || string.IsNullOrWhiteSpace(nspv.GetMetadata("Value")))) { task.LogError("Invalid parameters. NuSpecPropValues must be an array of Property and Value. " + NuSpecPropValuesUsage); return(false); } foreach (var nspv in nuSpecPropValues) { propValues[nspv.GetMetadata("Property")] = new PropertyEdit(nspv.GetMetadata("Value"), nspv.GetMetadata("EditMode")); } } else if (nuSpecProperty != null && nuSpecValue != null) { if (string.IsNullOrWhiteSpace(nuSpecProperty)) { task.LogError("Invalid parameters. MyNuSpecProperty cannot be empty. " + NuSpecSinglePropValueUsage); return(false); } propValues[nuSpecProperty] = new PropertyEdit(nuSpecValue, editMode); } else if (failIfEmpty) { task.LogError( $"Invalid parameters. Provide at least one of NuSpecPropValues or (NuSpecProperty and NuSpecValue) parameter.\n\n{NuSpecSinglePropValueUsage}\n\n{NuSpecPropValuesUsage}"); return(false); } else { task.LogInfo($"No content provided to write to {nuSpecFilePath}. Exiting."); return(true); } if (File.Exists(nuSpecFilePath) == false) { task.LogError($"Could not find file {nuSpecFilePath}, make sure it exists and its permissions are correct."); return(false); } var doc = XDocument.Load(nuSpecFilePath); var package = doc.Root; if (package == null || package.Name.LocalName != "package") { task.LogError($"Invalid NuSpec file '{nuSpecFilePath}': <package> does not exist, got {package?.Name} instead"); return(false); } var ns = doc.Root.Name.Namespace; var section = package.Element(ns + nuSpecSection); if (section == null) { task.LogError($"Invalid section '{nuSpecSection}': section does not exist"); return(false); } foreach (var propValue in propValues) { XElement prop = section.Element(ns + propValue.Key); if (prop == null) { section.Add(prop = new XElement(ns + propValue.Key)); } switch (propValue.Value.EditMode) { case "Append": prop.Value += propValue.Value.Value; break; case "AppendLine": prop.Value += "\\n" + propValue.Value.Value; break; case "Insert": prop.Value = propValue.Value.Value + prop.Value; break; case "InsertLine": prop.Value = propValue.Value.Value + "\\n" + prop.Value; break; case "Replace": default: prop.Value = propValue.Value.Value; break; } } doc.Save(nuSpecFilePath); return(true); }
public static PropertyEditApproveListModel ToListModel(this PropertyEdit entity) { return(entity.MapTo <PropertyEdit, PropertyEditApproveListModel>()); }
public void OnPropertyEdit(Property property, int index = 0) { $"WorldCon.OnPropertyEdit(\"{property}\", index: {index});".Spit(); PropertyEdit?.Invoke(this, new PropertyEditEventArgs(property, index)); }