Пример #1
0
        public async Task <ActualResult> UpdateAsync(HobbyEmployeesDTO item)
        {
            try
            {
                _context.Entry(_mapper.Map <HobbyEmployees>(item)).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(new ActualResult());
            }
            catch (Exception exception)
            {
                return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception)));
            }
        }
        public async Task <ActualResult> CreateAsync(HobbyEmployeesDTO item)
        {
            try
            {
                await _context.HobbyEmployees.AddAsync(_mapperService.Mapper.Map <HobbyEmployees>(item));

                await _context.SaveChangesAsync();

                return(new ActualResult());
            }
            catch (Exception exception)
            {
                return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception)));
            }
        }
Пример #3
0
        public async Task <ActualResult <string> > CreateAsync(HobbyEmployeesDTO item)
        {
            try
            {
                var hobbyEmployees = _mapper.Map <HobbyEmployees>(item);
                await _context.HobbyEmployees.AddAsync(hobbyEmployees);

                await _context.SaveChangesAsync();

                var hashId = HashHelper.EncryptLong(hobbyEmployees.Id);
                return(new ActualResult <string> {
                    Result = hashId
                });
            }
            catch (Exception exception)
            {
                return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception)));
            }
        }