public PropertyDto CopyTo(PropertyDto dto) { dto.Name = this.Name; dto.Version = this.Version; BaseCopyTo <PropertyDto>(dto); return(dto); }
private ICollection <PropertyDto> getPropertiesFromString(string properties) { IList <PropertyDto> result = new List <PropertyDto>(); var listOfProperityObjects = JsonConvert.DeserializeObject <PropertiesResponse>(properties); listOfProperityObjects.Properties.ForEach(property => { var newPropertyDto = new PropertyDto { Id = property.Id, YearBuilt = (property.Physical != null) ? property.Physical.YearBuilt : null, ListPrice = (property.Financial != null) ? property.Financial.ListPrice : null, MonthlyRent = (property.Financial != null) ? property.Financial.MonthlyRent : null, Address = new AddressDto { AddressOne = property.Address.AddressOne, AddressTwo = property.Address.AddressTwo, City = property.Address.City, Country = property.Address.Country, County = property.Address.County, District = property.Address.District, State = property.Address.State, Zip = property.Address.Zip, ZipPlus4 = property.Address.ZipPlus4 } }; newPropertyDto.calculateGrossYield(); result.Add(newPropertyDto); }); return(result); }
public Property CopyFrom(PropertyDto dto) { this.Name = dto.Name; this.Version = dto.Version; BaseCopyFrom <Property>(dto); return(this); }
public async Task <IActionResult> Post([FromBody] PropertyDto property) { try { if (property == null) { throw new Exception("Missing parameter (property)!"); } var value = await this._Dao.Create(property); if (value == null || value.Id == 0) { throw new Exception(); } return(Created($"property/{value.Id}", value)); } catch (Exception ex) { switch (ex.InnerException) { case Exception exception: return(BadRequest(exception.Message)); // Not InnerException default: return(NoContent()); } } }
public async Task <IActionResult> Put(int?id, [FromBody] PropertyDto property) { try { if (property == null) { throw new Exception("Missing parameter (property)!"); } if (id.Value == 0) { throw new Exception("The resource id must not be 0!"); } property.Id = id.Value; await this._Dao.Update(property); return(Accepted()); } catch (Exception ex) { switch (ex.InnerException) { case Exception exception: return(BadRequest(exception.Message)); // Not InnerException default: return(NoContent()); } } }
public async Task AddPropertyAsync(PropertyDto propertyDto) { Property newProperty = _mapper.Map <Property>(propertyDto); await _propertyDBContext.Property.AddAsync(newProperty); await _propertyDBContext.SaveChangesAsync(); }
private static void ProcessProperties(CheckOptions checkOptions, PropertyInfo[] properties, int propertiesCount, TypeDto typeDto) { for (int n = 0; n < propertiesCount; n++) { var pInfo = properties[n]; var pDto = new PropertyDto { Name = pInfo.ToString() }; typeDto.Properties.Add(pDto); if (!checkOptions.LogOnlyMissing) { Log.Write(Verbosity.Normal, LogLevel.Information, " Processing property {0} of {1}", n + 1, propertiesCount); } var propertyDocXml = DocsService.GetXmlFromMember(pInfo, false); pDto.XmlDescription = GetInnerText(propertyDocXml); if (string.IsNullOrEmpty(pDto.XmlDescription)) { Log.Write(Verbosity.Normal, LogLevel.Warning, " PROPERTY: {0} XML: {1}", pDto.Name, MISSING_XML); } else if (!checkOptions.LogOnlyMissing) { Log.Write(Verbosity.Normal, LogLevel.Information, " PROPERTY: {0} XML: {1}", pDto.Name, pDto.XmlDescription); } } }
public IActionResult Post([FromBody] PropertyDto property) { var PropertiesCount = PropertiesDataStore.Current.Properties.Count; PropertiesDataStore.Current.Properties.Insert(PropertiesCount, property); return(Ok()); }
public async Task UpdateProperty_WithValidPropertyValues_UpdatesProperty() { // arrange var existingProject = await this.PrepareProject(); var existingEntity = await this.PrepareEntity(existingProject.Id); var existingProperty = await this.PrepareProperty(existingProject.Id, existingEntity.Id); var value = new PropertyDto { Name = "New Property Name", Description = "New Property Description", PropertyType = "Zuehlke.Eacm.String" }; // act HttpResponseMessage response = await this.context.Client.PutAsJsonAsync($"api/projects/{existingProject.Id}/entities/{existingEntity.Id}/properties/{existingProperty.Id}", value); // arrange Assert.True(response.IsSuccessStatusCode); var propertyDto = await this.context.Client.ReadAsAsync <PropertyDto>($"api/projects/{existingProject.Id}/entities/{existingEntity.Id}/properties/{existingProperty.Id}"); Assert.Equal(value.Name, propertyDto.Name); Assert.Equal(value.Description, propertyDto.Description); Assert.Equal(value.PropertyType, propertyDto.PropertyType); }
public IActionResult Put(int id, [FromBody] PropertyDto property) { var index = PropertiesDataStore.Current.Properties.FindIndex(p => p.Id == id); PropertiesDataStore.Current.Properties[index] = property; return(Ok()); }
public async Task <IActionResult> CreateProperty(PropertyDto property) { property = await _propertyService.InsertAsync(property); var response = new ApiResponse <PropertyDto>(property); return(Ok(response)); }
public async Task <PropertyDto> AddAsync(PropertyDto property) { var entity = await OwnerPropertyDbContext.Properties.AddAsync(property.MapTo <Property>()); await SaveChangesAsync(); return(entity.Entity.MapTo <PropertyDto>()); }
public static void ExtUpdate(this Property value, PropertyDto obj) { value.Category = obj.Category; value.Description = obj.Description; value.Price = obj.Price; value.Rooms = obj.Rooms; value.Surface = obj.Surface; value.Title = obj.Title; }
public void Property_CRUD() { var proxy = new ProxyService <DeviceService>(new DeviceService(new ServiceContext())); //arrange var dto = testUtil.PropertyDto(); //Create var rpInsert = proxy.RunAsync(x => x.InsertProperty(dto)); rpInsert.Wait(); Assert.True(rpInsert.Result.Data > 0); //Read long identity = rpInsert.Result.Data; var rpGet = proxy.RunAsync(x => x.GetProperty(identity)); rpGet.Wait(); Assert.True(rpInsert.Result.Data == rpGet.Result.Data.Id); //Update var tmpDto = rpGet.Result.Data; tmpDto.Name = "Name updated!"; var rpUpdate = proxy.RunAsync(x => x.UpdateProperty(tmpDto)); rpUpdate.Wait(); var rpUpdateGet = proxy.RunAsync(x => x.GetProperty(identity)); rpUpdateGet.Wait(); Assert.Equal(rpUpdateGet.Result.Data.Name, tmpDto.Name); //Delete var rpDelete = proxy.RunAsync(x => x.DeleteProperty(identity)); rpDelete.Wait(); var rpDeleteGet = proxy.RunAsync(x => x.GetProperty(identity)); rpDeleteGet.Wait(); Assert.True(rpDeleteGet.Result.Data == null); //List var queryDto = new PropertyDto { }; var pagingDto = new PagingDto { pageSize = 3, pageNumber = 1 }; var rpList = proxy.RunAsync(x => x.ListProperty(queryDto, pagingDto));//List rpList.Wait(); Assert.True(rpList?.Result.Data != null && rpList.Result.Data.Any()); //assert //cleaup var rpHardDelete = proxy.RunAsync(x => x.DeleteHardProperty(identity)); }
public static PropertyModel From(PropertyDto result) { return(new PropertyModel { PropertyId = result.PropertyId, PropertyName = result.PropertyName, PropertyAddressFull = $"{result.PropertyAddressLine1}\n{result.PropertyAddressLine2}\n{result.PropertyAddressCountry}" }); }
private bool CheckEntity(PropertyDto dto) { if (dto != null) { if (string.IsNullOrEmpty(dto.AgentId)) { return(false); } if (dto.Area < 0) { return(false); } if (string.IsNullOrEmpty(dto.City)) { return(false); } if (string.IsNullOrEmpty(dto.Street)) { return(false); } if (string.IsNullOrEmpty(dto.Country)) { return(false); } if (dto.ZipCode < 0) { return(false); } if (dto.Price < 0) { return(false); } if (dto.NumberOfBathrooms < 0) { return(false); } if (dto.NumberOfBedrooms < 0) { return(false); } if (dto.NumberOfGarages < 0) { return(false); } if (dto.NumberOfParkingSpaces < 0) { return(false); } return(true); } else { return(false); } }
public async Task <IActionResult> UpdateProperty(int id, PropertyDto property) { property.Id = id; await _propertyService.UpdateAsync(property); var response = new ApiResponse <PropertyDto>(property); return(Ok(response)); }
public async Task <ServiceResponse <IEnumerable <PropertyDto> > > ListProperty([FromBody] IDictionary <string, object> data) { if (data == null) { throw new System.ArgumentNullException(nameof(data)); } PropertyDto searchDto = JsonConvert.DeserializeObject <PropertyDto>(data["searchDto"].ToString()); PagingDto pagingDto = JsonConvert.DeserializeObject <PagingDto>(data["pagingDto"].ToString()); return(await Sm.DeviceService.RunAsync(x => x.ListProperty(searchDto, pagingDto))); }
public async Task <PropertyDto> UpdateAsync(PropertyDto property) { var currentProperty = await GetEntityByIdAsync(property.Id); var newProperty = property.MapTo <Property>(); OwnerPropertyDbContext.Entry(currentProperty).CurrentValues.SetValues(newProperty); await SaveChangesAsync(); return(newProperty.MapTo <PropertyDto>()); }
public async Task <ActionResult> UpdateProperty(PropertyDto propertyDto) { var property = _mapper.Map <Property>(propertyDto); this._unitOfWork.PropertyRepository.UpdateProperty(property); if (await _unitOfWork.SaveAll()) { return(Ok()); } return(BadRequest("Error updating property")); }
public HttpResponseMessage ValidateEmail(PropertyDto dto) { var propertyValidation = dto.ValidateEmail(this.AccountSession, dto.ValidationMode); if (propertyValidation.IsValid) { return(this.Request.CreateResponse(HttpStatusCode.OK, new { success = true })); } // invalid parameters, generate response return(CreateInvalidResponse(propertyValidation)); }
public async Task <ActionResult> AddProperty(PropertyDto propertyDto) { var property = _mapper.Map <Property>(propertyDto); property.CreatedAt = DateTime.UtcNow; this._unitOfWork.PropertyRepository.AddProperty(property); if (await _unitOfWork.SaveAll()) { return(Ok()); } return(BadRequest("Error adding property")); }
public ServiceResponse <IEnumerable <PropertyDto> > ListProperty(PropertyDto propertyDto, PagingDto pagingDto) { var Rm = new RepositoryManager(ServiceContext); IEnumerable <Property> list = Rm.PropertyRepository.List(propertyDto, ref pagingDto); IEnumerable <PropertyDto> restulList = list.Select(entity => entity.CopyTo(new PropertyDto())).ToList(); if (list == null || !list.Any()) { throw new ServiceException(ExceptionType.Warning, Translate(MessagesConstants.WRN_RECORD_NOT_FOUND)); } return(new ServiceResponse <IEnumerable <PropertyDto> >(restulList, pagingDto.count)); }
public async Task <IHttpActionResult> PostProperty(PropertyDto propertyDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } propertyDto.Id = Guid.NewGuid(); propertyDto.Created = DateTime.UtcNow; await this.propertiesRepository.CreateProperty(Mapper.MapPropertyDtoToEntity(propertyDto)); return(CreatedAtRoute("DefaultApi", new { id = propertyDto.Id }, propertyDto)); }
public async Task <IHttpActionResult> GetProperty(Guid id) { var dbResult = await this.propertiesRepository.GetProperty(id); if (dbResult == null) { return(NotFound()); } PropertyDto property = Mapper.MapPropertyEntityToDto(dbResult, true); return(Ok(property)); }
public async Task <PropertyDto> CreateAsync(PropertyDto create) { if (CheckEntity(create)) { var result = db.Properties.Add(mapper.Map <Property>(create)); await db.SaveChangesAsync(); return(mapper.Map <PropertyDto>(result.Entity)); } else { throw new InvalidQueryParamsException(); } }
private async Task <PropertyDto> PrepareProperty(Guid projectId, Guid entityId) { var value = new PropertyDto { Name = $"New Property Name {Guid.NewGuid()}", Description = "New Property Description", PropertyType = "Zuehlke.Eacm.String" }; HttpResponseMessage response = await this.context.Client.PostAsJsonAsync($"api/projects/{projectId}/entities/{entityId}/properties", value); return(await response.ReadAsAsync <PropertyDto>()); }
public async Task <IActionResult> EditProperty(PropertyDto model) { if (ModelState.IsValid) { var property = await _converterHelper.ToPropertyAsync(model, false); _dataContext.Properties.Update(property); await _dataContext.SaveChangesAsync(); return(RedirectToAction($"Details/{model.OwnerId}")); } return(View(model)); }
public static Property MapPropertyDtoToEntity(PropertyDto propertyDto) { return(new Property() { Id = propertyDto.Id, Name = propertyDto.Name, Price = propertyDto.Price, Description = propertyDto.Description, Sold = propertyDto.Sold, OwnerId = propertyDto.Owner.UserId, Created = propertyDto.Created, Location = Mapper.MapAddressDtoToEntity(propertyDto.Location) }); }
public Task Update(PropertyDto obj) { return (Task.Factory.StartNew(() => { var entity = this._Context.Properties.Find(obj.Id); entity.ExtUpdate(obj); this._Context.Properties.Update(entity); this._Context.SaveChanges(); })); }
public void PropertyChange_DtoPropertyNotChanged_NoChangeInValueAndPropertyChangedIsNotRaised() { var dto = new TestDto (); var propertyDto = new PropertyDto { Key = 1, Name = "Test" }; bool propertyChanged = false; dto.PropertyChanged += ( s, e ) => { propertyChanged = true; }; dto.PropertyDto = propertyDto; Assert.AreEqual ( dto.PropertyDto, propertyDto ); Assert.IsTrue ( propertyChanged ); propertyChanged = false; dto.PropertyDto = propertyDto; Assert.AreEqual ( dto.PropertyDto, propertyDto ); Assert.IsFalse ( propertyChanged ); }
public void PropertyChange_DtoPropertyChanged_SetsNewValueAndRaisesPropertyChanged() { var dto = new TestDto (); var propertyDto1 = new PropertyDto { Key = 1, Name = "Test1" }; var propertyDto2 = new PropertyDto { Key = 2, Name = "Test2" }; bool propertyChanged = false; dto.PropertyChanged += ( s, e ) => { propertyChanged = true; }; dto.PropertyDto = propertyDto1; Assert.AreEqual ( dto.PropertyDto, propertyDto1 ); Assert.IsTrue ( propertyChanged ); propertyChanged = false; dto.PropertyDto = propertyDto2; Assert.AreEqual ( dto.PropertyDto, propertyDto2 ); Assert.IsTrue ( propertyChanged ); }