public ActionResult Put(Guid id, [FromBody] AssociationApiModel associationViewModel) { try { ApiResponse serviceResponse = this._associationService.GetById(id); if (serviceResponse.IsSuccess() == false) { return(new ValidationErrorResult(serviceResponse)); } Association association = serviceResponse.GetData <Association>(); _mapper.Map(associationViewModel, association); serviceResponse = this._associationService.Update(id, association); if (serviceResponse.IsSuccess()) { return(new ObjectUpdatedResult(serviceResponse.Id.Value)); } { return(new ValidationErrorResult(serviceResponse)); } } catch (Exception ex) { return(new UnknownErrorResult(ex, base._errorEnabled)); } }
public CommunityApiModel MapGet(Community community, LocationElemensDto locationElementsDto, List <Section> sections) { BasicInfoApiModel basicInfoApiModel = new BasicInfoApiModel(); AssociationApiModel associationApiModel = new AssociationApiModel(); LocationApiModel locationApiModel = new LocationApiModel(); SelectedLocationApiModel selectedLocationViewModel = new SelectedLocationApiModel(); _mapper.Map(community, basicInfoApiModel); _mapper.Map(community.Association, associationApiModel); _mapper.Map(community.Location, locationApiModel); selectedLocationViewModel.Countries = Map(locationElementsDto.Countries); selectedLocationViewModel.States = Map(locationElementsDto.States); selectedLocationViewModel.Cities = Map(locationElementsDto.Cities); selectedLocationViewModel.Areas = Map(locationElementsDto.Areas); selectedLocationViewModel.SubAreas = Map(locationElementsDto.SubAreas); JObject jObject = new JObject(); Map(jObject, sections); return(new CommunityApiModel() { BasicInfo = basicInfoApiModel, Association = associationApiModel, SelectedLocation = selectedLocationViewModel, Sections = jObject.ToObject <Dictionary <string, object> >() }); }
public ActionResult Post(Guid id, [FromBody] AssociationApiModel associationViewModel) { try { Association association = new Association(); _mapper.Map(associationViewModel, association); ApiResponse serviceResponse = this._associationService.Create(association, id); if (serviceResponse.IsSuccess()) { return(new ObjectCreatedResult("association", serviceResponse.Id.Value)); } else { return(new ValidationErrorResult(serviceResponse)); } } catch (Exception ex) { return(new UnknownErrorResult(ex, base._errorEnabled)); } }