Exemplo n.º 1
0
        private async Task CreateNoticeAsync(NoticeCreateOrUpdateInput input)
        {
            var notice = ObjectMapper.Map <Notice>(input);

            notice.UserId = AbpSession.UserId;
            await _noticeRepository.InsertAsync(notice);
        }
Exemplo n.º 2
0
        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"));
            }
        }
Exemplo n.º 3
0
        public async Task CreateOrUpdateNotice(NoticeCreateOrUpdateInput input)
        {
            await CheckValidation(input);

            if (input.Id.HasValue)
            {
                await UpdateNoticeAsync(input);
            }
            else
            {
                await CreateNoticeAsync(input);
            }
        }
Exemplo n.º 4
0
        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);
        }