public async Task <ActualResult> CreateAsync(PrivateHouseEmployeesDTO item, PrivateHouse type) { try { switch (type) { case PrivateHouse.PrivateHouse: await _context.PrivateHouseEmployees.AddAsync(_mapperService.Mapper.Map <PrivateHouseEmployees>(item)); await _context.SaveChangesAsync(); return(new ActualResult()); case PrivateHouse.UniversityHouse: var check = await CheckDate(item); if (check.IsValid) { await _context.PrivateHouseEmployees.AddAsync(_mapperService.Mapper.Map <PrivateHouseEmployees>(item)); await _context.SaveChangesAsync(); return(new ActualResult()); } return(check); default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult> CreateAsync(TravelChildrenDTO item) { try { await _context.EventChildrens.AddAsync(_mapperService.Mapper.Map <EventChildrens>(item)); await _context.SaveChangesAsync(); return(new ActualResult()); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult> CreateAsync(FamilyDTO item) { try { await _context.Family.AddAsync(_mapperService.Mapper.Map <DAL.Entities.Family>(item)); await _context.SaveChangesAsync(); return(new ActualResult()); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult> CreateAsync(DepartmentalDTO dto) { try { await _context.AddressPublicHouse.AddAsync(_mapperService.Mapper.Map <AddressPublicHouse>(dto)); await _context.SaveChangesAsync(); return(new ActualResult()); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult> CreateAsync(DirectoryDTO dto) { try { await _context.Hobby.AddAsync(_mapperService.Mapper.Map <Hobby>(dto)); await _context.SaveChangesAsync(); return(new ActualResult()); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task<ActualResult<string>> CreateAsync(TourDTO dto) { try { var tour = _mapper.Map<Event>(dto); await _context.Event.AddAsync(tour); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(tour.Id); return new ActualResult<string> { Result = hashId }; } catch (Exception exception) { return new ActualResult<string>(DescriptionExceptionHelper.GetDescriptionError(exception)); } }
public async Task <ActualResult> CreateAsync(FluorographyEmployeesDTO item) { try { await _context.FluorographyEmployees.AddAsync(_mapperService.Mapper.Map <FluorographyEmployees>(item)); await _context.SaveChangesAsync(); return(new ActualResult()); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult> CreateAsync(ApartmentAccountingEmployeesDTO item) { try { var mapping = _mapperService.Mapper.Map <ApartmentAccountingEmployees>(item); await _context.ApartmentAccountingEmployees.AddAsync(mapping); await _context.SaveChangesAsync(); return(new ActualResult()); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult> CreateAsync(PrivilegeEmployeesDTO dto) { try { dto.CheckPrivileges = true; await _context.PrivilegeEmployees.AddAsync(_mapperService.Mapper.Map <PrivilegeEmployees>(dto)); await _context.SaveChangesAsync(); return(new ActualResult()); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <string> > AddEmployeeAsync(CreateEmployeeDTO dto) { try { var employee = _mapper.Map <DAL.Entities.Employee>(dto); employee.PositionEmployees = _mapper.Map <PositionEmployees>(dto); switch (dto.TypeAccommodation) { case AccommodationType.PrivateHouse: case AccommodationType.FromUniversity: employee.PrivateHouseEmployees.Add(_mapper.Map <PrivateHouseEmployees>(dto)); break; case AccommodationType.Dormitory: case AccommodationType.Departmental: employee.PublicHouseEmployees.Add(_mapper.Map <PublicHouseEmployees>(dto)); break; default: throw new ArgumentOutOfRangeException(); } if (dto.SocialActivity) { employee.SocialActivityEmployees = _mapper.Map <SocialActivityEmployees>(dto); } if (dto.Privileges) { employee.PrivilegeEmployees = _mapper.Map <PrivilegeEmployees>(dto); } await _context.Employee.AddAsync(employee); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(employee.Id); return(new ActualResult <string> { Result = hashId }); } catch (Exception exception) { return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult> CreateAsync(PrivateHouseEmployeesDTO item, PrivateHouse type) { try { switch (type) { case PrivateHouse.PrivateHouse: { var privateHouse = _mapper.Map <PrivateHouseEmployees>(item); await _context.PrivateHouseEmployees.AddAsync(privateHouse); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(privateHouse.Id); return(new ActualResult <string> { Result = hashId }); } case PrivateHouse.UniversityHouse: { var check = await CheckDate(item); if (check.IsValid) { var universityHouse = _mapper.Map <PrivateHouseEmployees>(item); await _context.PrivateHouseEmployees.AddAsync(universityHouse); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(universityHouse.Id); return(new ActualResult <string> { Result = hashId }); } return(check); } default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <string> > CreateAsync(GiftChildrenDTO item) { try { var giftChildren = _mapper.Map <GiftChildrens>(item); await _context.GiftChildrens.AddAsync(giftChildren); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(giftChildren.Id); return(new ActualResult <string> { Result = hashId }); } catch (Exception exception) { return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <string> > CreateAsync(WellnessFamilyDTO item) { try { var wellnessFamily = _mapper.Map <EventFamily>(item); await _context.EventFamily.AddAsync(wellnessFamily); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(wellnessFamily.Id); return(new ActualResult <string> { Result = hashId }); } catch (Exception exception) { return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <string> > CreateAsync(DormitoryDTO dto) { try { var dormitory = _mapper.Map <AddressPublicHouse>(dto); await _context.AddressPublicHouse.AddAsync(dormitory); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(dormitory.Id); return(new ActualResult <string> { Result = hashId }); } catch (Exception exception) { return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <string> > CreateAsync(DirectoryDTO dto) { try { var hobby = _mapper.Map <Hobby>(dto); await _context.Hobby.AddAsync(hobby); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(hobby.Id); return(new ActualResult <string> { Result = hashId }); } catch (Exception exception) { return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <string> > CreateAsync(ActivityEmployeesDTO item) { try { var activityEmployees = _mapper.Map <ActivityEmployees>(item); await _context.ActivityEmployees.AddAsync(activityEmployees); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(activityEmployees.Id); return(new ActualResult <string> { Result = hashId }); } catch (Exception exception) { return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <string> > CreateAsync(PrivilegeEmployeesDTO dto) { try { dto.CheckPrivileges = true; var privilegeEmployees = _mapper.Map <PrivilegeEmployees>(dto); await _context.PrivilegeEmployees.AddAsync(privilegeEmployees); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(privilegeEmployees.Id); return(new ActualResult <string> { Result = hashId }); } catch (Exception exception) { return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult> AddEmployeeAsync(CreateEmployeeDTO dto) { try { var employee = _mapperService.Mapper.Map <DAL.Entities.Employee>(dto); employee.PositionEmployees = _mapperService.Mapper.Map <PositionEmployees>(dto); if (dto.TypeAccommodation == AccommodationType.PrivateHouse || dto.TypeAccommodation == AccommodationType.FromUniversity) { employee.PrivateHouseEmployees.Add(_mapperService.Mapper.Map <PrivateHouseEmployees>(dto)); } if (dto.TypeAccommodation == AccommodationType.Dormitory || dto.TypeAccommodation == AccommodationType.Departmental) { employee.PublicHouseEmployees.Add(_mapperService.Mapper.Map <PublicHouseEmployees>(dto)); } if (dto.SocialActivity) { employee.SocialActivityEmployees = _mapperService.Mapper.Map <SocialActivityEmployees>(dto); } if (dto.Privileges) { employee.PrivilegeEmployees = _mapperService.Mapper.Map <PrivilegeEmployees>(dto); } await _context.Employee.AddAsync(employee); await _context.SaveChangesAsync(); return(new ActualResult()); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult> UpdateAsync(PositionEmployeesDTO dto) { try { var validation = await CheckDate(dto); if (validation.IsValid) { _context.Entry(_mapper.Map <PositionEmployees>(dto)).State = EntityState.Modified; await _context.SaveChangesAsync(); return(new ActualResult()); } return(validation); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
//------------------------------------------------------------------------------------------------------------------- public async Task <ActualResult> CreateMainSubdivisionAsync(CreateSubdivisionDTO dto) { try { await _context.Subdivisions.AddAsync(_mapperService.Mapper.Map <Subdivisions>(dto)); await _context.SaveChangesAsync(); return(new ActualResult()); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
//------------------------------------------------------------------------------------------------------------------- public async Task <ActualResult <string> > CreateMainSubdivisionAsync(CreateSubdivisionDTO dto) { try { var subdivision = _mapper.Map <Subdivisions>(dto); await _context.Subdivisions.AddAsync(subdivision); await _context.SaveChangesAsync(); var hashId = HashHelper.EncryptLong(subdivision.Id); return(new ActualResult <string> { Result = hashId }); } catch (Exception exception) { return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }