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

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

                await _context.SaveChangesAsync();

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

                await _context.SaveChangesAsync();

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