public async Task <ServiceResponse <Society> > GetAsync(Guid id) { var response = new ServiceResponse <Society>(); var society = await this._societyRepository.GetAsync(id); if (society == null) { response.ErrorMessages.Add(new ValidationFailure("", "Search did not yield any society")); return(response); } Domain.DTO.Society.Society societyDto = AutoMapper.Mapper.Map <Society>(society); response.Data = societyDto; return(response); }
public async Task <IActionResult> Create([FromBody] Domain.DTO.Society.Society society) { if (society == null) { return(BadRequest()); } society.CreatedBy = this.LoggedInUserId; society.CreatedDate = DateTime.UtcNow; society.UpdatedBy = this.LoggedInUserId; society.UpdatedDate = DateTime.UtcNow; society.Id = Guid.NewGuid(); var response = await this._societyService.CreateSociety(society); if (response.Successful) { return(Ok(response.Data)); } return(BadRequest(response.ErrorMessages)); // return Ok(this._societyService.CreateSociety(society)); }
public async Task <IActionResult> Update([FromBody] Domain.DTO.Society.Society society) { if (society == null || society.Id == null) { return(BadRequest()); } var exists = await this._societyService.IsExistsAsync(society.Id); if (!exists) { return(NotFound()); } society.UpdatedBy = this.LoggedInUserId; society.UpdatedDate = DateTime.UtcNow; var response = await this._societyService.UpdateAsync(society); if (response.Successful) { return(Ok(response.Data)); } return(BadRequest(response.ErrorMessages)); }
public static Apollo.Domain.Entity.Society.Society MapToSocietyEntity( Domain.DTO.Society.Society fromSocietyDTO) { return(Mapper.Map <Apollo.Domain.Entity.Society.Society>(fromSocietyDTO)); }