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

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

            if (input.Id.HasValue)
            {
                await UpdateNoticeAsync(input);
            }
            else
            {
                await CreateNoticeAsync(input);
            }
        }
Esempio 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);
        }