Beispiel #1
0
        public async Task <int> CreateOrEdit(CreateOrEditMemorizeKeywordDto input)
        {
            int insertedId = 0;

            try
            {
                if (input.Id == null)
                {
                    insertedId = await Create(input);
                }
                else
                {
                    await Update(input);
                }
            }
            catch (Exception e)
            {
                if (e.Message.StartsWith("An error occurred while updating the entries. See the inner exception for details."))
                {
                    // handle your violation
                    throw new UserFriendlyException(L("UniqueKeyword"));
                }
            }

            return(insertedId);
        }
Beispiel #2
0
        protected virtual async Task <int> Create(CreateOrEditMemorizeKeywordDto input)
        {
            var memorizeKeyword = ObjectMapper.Map <MemorizeKeyword>(input);

            if (AbpSession.TenantId != null)
            {
                memorizeKeyword.TenantId = (int?)AbpSession.TenantId;
            }

            var id = await _memorizeKeywordRepository.InsertAndGetIdAsync(memorizeKeyword);

            return(id);
        }
Beispiel #3
0
        protected virtual async Task Update(CreateOrEditMemorizeKeywordDto input)
        {
            var memorizeKeyword = await _memorizeKeywordRepository.FirstOrDefaultAsync((int)input.Id);

            ObjectMapper.Map(input, memorizeKeyword);
        }