private async Task CreateNoticeAsync(NoticeCreateOrUpdateInput input) { var notice = ObjectMapper.Map <Notice>(input); notice.UserId = AbpSession.UserId; await _noticeRepository.InsertAsync(notice); }
private async Task CheckValidation(NoticeCreateOrUpdateInput input) { var existingObj = (await _noticeRepository.GetAll().AsNoTracking() .FirstOrDefaultAsync(l => l.Title == input.Title)); if (existingObj != null && existingObj.Id != input.Id) { throw new UserFriendlyException(L("ThisCodeAlreadyExists")); } }
public async Task CreateOrUpdateNotice(NoticeCreateOrUpdateInput input) { await CheckValidation(input); if (input.Id.HasValue) { await UpdateNoticeAsync(input); } else { await CreateNoticeAsync(input); } }
public async Task <NoticeCreateOrUpdateInput> GetNoticeForEdit(NullableIdDto <int> input) { //Getting all available roles var output = new NoticeCreateOrUpdateInput(); if (input.Id.HasValue) { //Editing an existing user var notice = await _noticeRepository.GetAsync(input.Id.Value); if (notice != null) { ObjectMapper.Map <Notice, NoticeCreateOrUpdateInput>(notice, output); } } return(output); }