private IEnumerable<PropertyViewModel> MapToPropertyViewModel(List<Property> properties) { if (!properties.Any()) return Enumerable.Empty<PropertyViewModel>(); var props = new List<PropertyViewModel>(); foreach (var property in properties) { var model = new PropertyViewModel(); model.Description = property.Description; model.Cost = property.Cost; model.PropertyId = property.Id; props.Add(model); } return props; }
public void SaveProperty(PropertyViewModel model) { Property property; if (model.PropertyId != 0) property = this.clientProfileService.GetClientProperty(model.PropertyId); else property = new Property(); property.Cost = model.Cost; property.Description = model.Description; if (property.Id == 0) { Client client = this.clientProfileService.GetClient(model.ClientId); client.Properties.Add(property); } this.clientProfileService.Save(property); }
public ActionResult AddProperty(int? clientId, int? propertyId) { int resolvedClientId = this.ResolveClientId(clientId); PropertyViewModel model; if (propertyId.HasValue) { model = clientProfileManager.GetProperty(resolvedClientId, propertyId.Value); } else { model = new PropertyViewModel { ClientId = resolvedClientId }; } return this.View(model); }
public PropertyViewModel GetProperty(int clientId, int propertyId) { Property property = clientProfileService.GetClientProperty(propertyId); var model = new PropertyViewModel { Cost = property.Cost, Description = property.Description, ClientId = clientId, PropertyId = propertyId }; return model; }
public ActionResult AddProperty(PropertyViewModel model) { if (!ModelState.IsValid) return this.View(model); clientProfileManager.SaveProperty(model); return Json(true, JsonRequestBehavior.DenyGet); }