public BaseResponseDto Update(EnrollUpdateModel enrollUpdateModel) { BaseResponseDto responseDto = null; if (enrollUpdateModel == null) { responseDto = new BaseResponseDto { Status = 1, Message = "Faulthy enroll info" }; return(responseDto); } Enroll existingEnroll = null; try { existingEnroll = _uow.GetRepository <Enroll>() .GetAll() .FirstOrDefault(e => e.EnrollId == enrollUpdateModel.EnrollId); } catch (Exception e) { throw e; } if (existingEnroll == null) { responseDto = new BaseResponseDto { Status = 2, Message = "Not enrolled to sharing yet" }; return(responseDto); } existingEnroll.SharingId = enrollUpdateModel.SharingId; existingEnroll.SubscriptionId = enrollUpdateModel.SubscriptionId; existingEnroll.IsDisable = enrollUpdateModel.IsDisable; try { _uow.GetRepository <Enroll>().Update(existingEnroll); _uow.Commit(); } catch (Exception e) { throw e; } responseDto = new BaseResponseDto { Status = 0, Message = "Success" }; return(responseDto); }
public IActionResult Update(EnrollUpdateModel enrollUpdateModel) { BaseResponseDto responseDto = null; if (enrollUpdateModel == null) { return(BadRequest("Enroll info must not be null")); } try { responseDto = _enroll.Update(enrollUpdateModel); } catch (Exception e) { return(StatusCode(500, e)); } return(Ok(responseDto.Message)); }