public async Task <ActionResult> Update([FromBody] UserChecklistDto userChecklistDto) { var userEmail = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Email).Value; var response = await _dashboardService.Update(userChecklistDto, userEmail); if (!response.IsSuccessful) { return(new BadRequestObjectResult(response.ErrorMessage)); } return(new OkObjectResult(response)); }
public async Task <BasePlainResponse> Add(UserChecklistDto checklistDto, string userEmail) { var plainResponse = new BasePlainResponse(); var checklist = _mapper.Map <UserChecklist>(checklistDto); var user = await _unitOfWork.userRepository.GetByEmail(userEmail); checklist.User = user; checklist.CreatedDate = DateTime.UtcNow; await _unitOfWork.dashboardRepository.Create(checklist); await _unitOfWork.Save(); return(plainResponse); }
public async Task <ActionResult> AddList([FromBody] UserChecklistDto checklist) { var userEmail = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Email).Value; if (ModelState.IsValid) { var response = await _dashboardService.Add(checklist, userEmail); if (!response.IsSuccessful) { return(new BadRequestObjectResult(response.ErrorMessage)); } return(new OkObjectResult(response)); } return(BadRequest()); }
public async Task <BasePlainResponse> Update(UserChecklistDto userChecklistDto, string userEmail) { var checklistNotBelongToUserResponse = await DoesUserChecklistBelongToUser(userChecklistDto.Id, userEmail); if (!checklistNotBelongToUserResponse.IsSuccessful) { return(checklistNotBelongToUserResponse); } var checklistReponse = new BasePlainResponse(); _unitOfWork.dashboardRepository.Update(_mapper.Map <UserChecklist>(userChecklistDto)); await _unitOfWork.Save(); return(checklistReponse); }