public IActionResult CreatePointOfInterest(int mainAccountId, [FromBody] LandingPageDetailCreationDto landingPageDetail) { // Validation of PointOfInterest if (landingPageDetail == null) { return(BadRequest()); } if (landingPageDetail.UserId == landingPageDetail.Password) { ModelState.AddModelError("Description", "The provided description should be different from the name."); } if (!ModelState.IsValid) { return(BadRequest()); } if (!_landingPageRepository.AccountExists(mainAccountId)) { return(NotFound()); } var newIndividualAccount = Mapper.Map <Entities.LandingPageDetail>(landingPageDetail); _landingPageRepository.AddIndividualAccountForSummaryAccount(mainAccountId, newIndividualAccount); if (!_landingPageRepository.Save()) { return(StatusCode(500, "A problem happened while handlig your request.")); } var createdIndividualAccount = Mapper.Map <Models.LandingPageDetailDto>(newIndividualAccount); return(CreatedAtRoute("GetSingleSubAccountForMainAccount", new { mainAccountId = mainAccountId, subAccountId = createdIndividualAccount.Id }, createdIndividualAccount)); }
public IActionResult UpdateIndividualAccount(int mainAccountId, int subAccountId, [FromBody] LandingPageDetailCreationDto landingPageDetail) { // Validation of PointOfInterest if (landingPageDetail == null) { return(BadRequest()); } if (landingPageDetail.UserId == landingPageDetail.Password) { ModelState.AddModelError("Description", "The provided name and password should be different."); } if (!ModelState.IsValid) { return(BadRequest()); } if (!_landingPageRepository.AccountExists(mainAccountId)) { return(NotFound()); } var subAccountEntity = _landingPageRepository.GetLandingPageDetail(mainAccountId, subAccountId); if (subAccountEntity == null) { return(NotFound()); } Mapper.Map(landingPageDetail, subAccountEntity); if (!_landingPageRepository.Save()) { return(StatusCode(500, "A problem happened while handlig your request.")); } return(NoContent()); }