public async Task <ActualResult <ProductCategoryDTO> > GetAsync(int productKey) { try { var productCategory = await _context.DimProductCategory.FindAsync(productKey); if (productCategory == null) { return(new ActualResult <ProductCategoryDTO>(Errors.TupleDeleted)); } var result = _mapper.Map <ProductCategoryDTO>(productCategory); return(new ActualResult <ProductCategoryDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <ProductCategoryDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } throw new NotImplementedException(); }
public async Task <ActualResult <ApartmentAccountingEmployeesDTO> > GetAsync(string hashId) { try { var id = _hashIdUtilities.DecryptLong(hashId); var apartmentAccounting = await _context.ApartmentAccountingEmployees.FindAsync(id); if (apartmentAccounting == null) { return(new ActualResult <ApartmentAccountingEmployeesDTO>(Errors.TupleDeleted)); } var result = _mapperService.Mapper.Map <ApartmentAccountingEmployeesDTO>(apartmentAccounting); return(new ActualResult <ApartmentAccountingEmployeesDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <ApartmentAccountingEmployeesDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <GiftEmployeesDTO> > GetAsync(string hashId) { try { var id = HashHelper.DecryptLong(hashId); var gift = await _context.GiftEmployees.FindAsync(id); if (gift == null) { return(new ActualResult <GiftEmployeesDTO>(Errors.TupleDeleted)); } var result = _mapper.Map <GiftEmployeesDTO>(gift); return(new ActualResult <GiftEmployeesDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <GiftEmployeesDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <IEnumerable <CulturalFamilyDTO> > > GetAllAsync(string hashIdFamily) { try { var id = _hashIdUtilities.DecryptLong(hashIdFamily); var cultural = await _context.CulturalFamily .Include(x => x.IdCulturalNavigation) .Where(x => x.IdFamily == id) .OrderByDescending(x => x.DateVisit) .ToListAsync(); var result = _mapperService.Mapper.Map <IEnumerable <CulturalFamilyDTO> >(cultural); return(new ActualResult <IEnumerable <CulturalFamilyDTO> > { Result = result }); } catch (Exception exception) { return(new ActualResult <IEnumerable <CulturalFamilyDTO> >(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <IEnumerable <MaterialAidEmployeesDTO> > > GetAllAsync(string hashIdEmployee) { try { var id = _hashIdUtilities.DecryptLong(hashIdEmployee); var materialAid = await _context.MaterialAidEmployees .Include(x => x.IdMaterialAidNavigation) .Where(x => x.IdEmployee == id) .OrderByDescending(x => x.DateIssue) .ToListAsync(); var result = _mapperService.Mapper.Map <IEnumerable <MaterialAidEmployeesDTO> >(materialAid); return(new ActualResult <IEnumerable <MaterialAidEmployeesDTO> > { Result = result }); } catch (Exception exception) { return(new ActualResult <IEnumerable <MaterialAidEmployeesDTO> >(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <IEnumerable <TravelEmployeesDTO> > > GetAllAsync(string hashIdEmployee) { try { var id = _hashIdUtilities.DecryptLong(hashIdEmployee); var travel = await _context.EventEmployees .Include(x => x.IdEventNavigation) .Where(x => x.IdEmployee == id && x.IdEventNavigation.Type == TypeEvent.Travel) .OrderByDescending(x => x.StartDate) .ToListAsync(); var result = _mapperService.Mapper.Map <IEnumerable <TravelEmployeesDTO> >(travel); return(new ActualResult <IEnumerable <TravelEmployeesDTO> > { Result = result }); } catch (Exception exception) { return(new ActualResult <IEnumerable <TravelEmployeesDTO> >(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <SubdivisionDTO> > GetAsync(string hashId) { try { var id = _hashIdUtilities.DecryptLong(hashId); var subdivision = await _context.Subdivisions.FindAsync(id); if (subdivision == null) { return(new ActualResult <SubdivisionDTO>(Errors.TupleDeleted)); } var result = _mapperService.Mapper.Map <SubdivisionDTO>(subdivision); return(new ActualResult <SubdivisionDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <SubdivisionDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
//------------------------------------------------------------------------------------------ public async Task <ActualResult <FileDTO> > CreateReport(ReportPdfDTO dto) { try { var model = await FillModelReport(dto); var pdf = _reportGeneratorService.Generate(model); var reportBucketModel = _mapper.Map <ReportPdfBucketModel>(dto); reportBucketModel.Pdf = _mapper.Map <FileModel>(pdf); await _pdfBucketService.PutPdfObject(reportBucketModel); return(new ActualResult <FileDTO> { Result = _mapper.Map <FileDTO>(pdf) }); } catch (Exception exception) { return(new ActualResult <FileDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <PositionEmployeesDTO> > GetAsync(string hashIdEmployee) { try { var id = HashHelper.DecryptLong(hashIdEmployee); var position = await _context.PositionEmployees.FirstOrDefaultAsync(x => x.IdEmployee == id); if (position == null) { return(new ActualResult <PositionEmployeesDTO>(Errors.TupleDeleted)); } var result = _mapper.Map <PositionEmployeesDTO>(position); return(new ActualResult <PositionEmployeesDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <PositionEmployeesDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <DepartmentalDTO> > GetAsync(string hashId) { try { var id = HashHelper.DecryptLong(hashId); var departmental = await _context.AddressPublicHouse.FindAsync(id); if (departmental == null) { return(new ActualResult <DepartmentalDTO>(Errors.TupleDeleted)); } var result = _mapper.Map <DepartmentalDTO>(departmental); return(new ActualResult <DepartmentalDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <DepartmentalDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <DormitoryDTO> > GetAsync(string hashId) { try { var id = _hashIdUtilities.DecryptLong(hashId); var dormitory = await _context.AddressPublicHouse.FindAsync(id); if (dormitory == null) { return(new ActualResult <DormitoryDTO>(Errors.TupleDeleted)); } var result = _mapperService.Mapper.Map <DormitoryDTO>(dormitory); return(new ActualResult <DormitoryDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <DormitoryDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult> UpdateAsync(PositionEmployeesDTO dto) { try { var validation = await CheckDate(dto); if (validation.IsValid) { await _context.PositionEmployees.AddAsync(_mapperService.Mapper.Map <PositionEmployees>(dto)); await _context.SaveChangesAsync(); return(new ActualResult()); } return(validation); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
//------------------------------------------------------------------------------------------------------------------------------------------ public async Task <ActualResult <GeneralInfoEmployeeDTO> > GetMainInfoEmployeeAsync(string hashId) { try { var id = HashHelper.DecryptLong(hashId); var employee = await _context.Employee.FindAsync(id); if (employee == null) { return(new ActualResult <GeneralInfoEmployeeDTO>(Errors.TupleDeleted)); } var mapping = _mapper.Map <GeneralInfoEmployeeDTO>(employee); return(new ActualResult <GeneralInfoEmployeeDTO> { Result = mapping }); } catch (Exception exception) { return(new ActualResult <GeneralInfoEmployeeDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <IEnumerable <TourChildrenDTO> > > GetAllAsync(string hashIdChildren) { try { var id = HashHelper.DecryptLong(hashIdChildren); var tour = await _context.EventChildrens .Include(x => x.IdEventNavigation) .Where(x => x.IdChildren == id && x.IdEventNavigation.Type == TypeEvent.Tour) .OrderByDescending(x => x.StartDate) .ToListAsync(); var result = _mapper.Map <IEnumerable <TourChildrenDTO> >(tour); return(new ActualResult <IEnumerable <TourChildrenDTO> > { Result = result }); } catch (Exception exception) { return(new ActualResult <IEnumerable <TourChildrenDTO> >(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <IEnumerable <WellnessFamilyDTO> > > GetAllAsync(string hashIdFamily) { try { var id = HashHelper.DecryptLong(hashIdFamily); var wellness = await _context.EventFamily .Include(x => x.IdEventNavigation) .Where(x => x.IdFamily == id && x.IdEventNavigation.Type == TypeEvent.Wellness) .OrderByDescending(x => x.StartDate) .ToListAsync(); var result = _mapper.Map <IEnumerable <WellnessFamilyDTO> >(wellness); return(new ActualResult <IEnumerable <WellnessFamilyDTO> > { Result = result }); } catch (Exception exception) { return(new ActualResult <IEnumerable <WellnessFamilyDTO> >(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <ChildrenDTO> > GetAsync(string hashId) { try { var id = HashHelper.DecryptLong(hashId); var children = await _context.Children.FindAsync(id); if (children == null) { return(new ActualResult <ChildrenDTO>(Errors.TupleDeleted)); } var result = _mapper.Map <ChildrenDTO>(children); return(new ActualResult <ChildrenDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <ChildrenDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <IEnumerable <HobbyGrandChildrenDTO> > > GetAllAsync(string hashIdGrandChildren) { try { var id = HashHelper.DecryptLong(hashIdGrandChildren); var hobby = await _context.HobbyGrandChildrens .Include(x => x.IdHobbyNavigation) .Where(x => x.IdGrandChildren == id) .OrderBy(x => x.IdHobbyNavigation.Name) .ToListAsync(); var result = _mapper.Map <IEnumerable <HobbyGrandChildrenDTO> >(hobby); return(new ActualResult <IEnumerable <HobbyGrandChildrenDTO> > { Result = result }); } catch (Exception exception) { return(new ActualResult <IEnumerable <HobbyGrandChildrenDTO> >(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <DirectoryDTO> > GetAsync(string hashId) { try { var id = HashHelper.DecryptLong(hashId); var materialAid = await _context.MaterialAid.FindAsync(id); if (materialAid == null) { return(new ActualResult <DirectoryDTO>(Errors.TupleDeleted)); } var result = _mapper.Map <DirectoryDTO>(materialAid); return(new ActualResult <DirectoryDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <DirectoryDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <IEnumerable <ActivityChildrenDTO> > > GetAllAsync(string hashIdChildren) { try { var id = HashHelper.DecryptLong(hashIdChildren); var activity = await _context.ActivityChildrens .Include(x => x.IdActivitiesNavigation) .Where(x => x.IdChildren == id) .OrderByDescending(x => x.DateEvent) .ToListAsync(); var result = _mapper.Map <IEnumerable <ActivityChildrenDTO> >(activity); return(new ActualResult <IEnumerable <ActivityChildrenDTO> > { Result = result }); } catch (Exception exception) { return(new ActualResult <IEnumerable <ActivityChildrenDTO> >(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task AuditAsync(string email, string ipUser, Operations operation, Tables table, string columnName = null) { try { await _auditRepository.AuditAsync( new AuditContosoRetailDw { EmailUser = email, IpUser = ipUser, OperationId = (int)operation, OperationName = operation.ToString(), TableId = (int)table, TableName = table.ToString(), ColumnName = columnName, CreatedOn = DateTime.Now }); } catch (Exception exception) { new ActualResult <AuditContosoRetailDw>(DescriptionExceptionHelper.GetDescriptionError(exception)); } }
public async Task <ActualResult <IEnumerable <JournalDTO> > > FilterAsync(string email, DateTime startDate, DateTime endDate) { try { var result = await _auditRepository.FilterAsync(email, startDate, endDate); return(new ActualResult <IEnumerable <JournalDTO> > { Result = result.Select(journal => new JournalDTO { EmailUser = journal.EmailUser, DateTime = journal.DateTime, Operation = dictionatyOperations[journal.Operation], Tables = dictionatyTables[journal.Table], }).ToList() }); } catch (Exception exception) { return(new ActualResult <IEnumerable <JournalDTO> >(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <string> > CreateMainCurrencyAsync(CreateCurrencyDTO dto) { try { var currency = _mapper.Map <DimCurrency>(dto); var currentDateTime = DateTime.Now; currency.LoadDate = currentDateTime; currency.UpdateDate = currentDateTime; currency.EtlloadId = 1; await _context.DimCurrency.AddAsync(currency); await _context.SaveChangesAsync(); return(new ActualResult <string> { Result = currency.CurrencyKey.ToString() }); } catch (Exception exception) { return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult> UpdatePersonalDataAsync(AccountDTO dto) { try { var user = await _userManager.FindByIdAsync(dto.HashId); if (user != null) { user.FirstName = dto.FirstName; user.LastName = dto.LastName; user.Patronymic = dto.Patronymic; var result = await _userManager.UpdateAsync(user); return(result.Succeeded ? new ActualResult() : new ActualResult(Errors.DataBaseError)); } return(new ActualResult(Errors.UserNotFound)); } catch (Exception exception) { return(new ActualResult(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <CustomerDTO> > GetAsync(string hashId) { try { //var id = HashHelper.DecryptLong(hashId); var id = Convert.ToInt32(hashId);// HashHelper.DecryptLong(hashId); var customer = await _context.DimCustomer.FindAsync(id); if (customer == null) { return(new ActualResult <CustomerDTO>(Errors.TupleDeleted)); } var result = _mapper.Map <CustomerDTO>(customer); return(new ActualResult <CustomerDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <CustomerDTO>(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 <IEnumerable <ResultSearchDTO> > > SearchAccommodation(AccommodationType type, string hashId) { try { return(await Task.Run(() => { var id = HashHelper.DecryptLong(hashId); switch (type) { case AccommodationType.Dormitory: case AccommodationType.Departmental: var searchByPublicHouse = _context.Employee .Include(x => x.PositionEmployees.IdSubdivisionNavigation.InverseIdSubordinateNavigation) .Include(x => x.PublicHouseEmployees) .Where(x => x.PublicHouseEmployees.AsQueryable().Any(t => t.IdAddressPublicHouse == id)); return new ActualResult <IEnumerable <ResultSearchDTO> > { Result = ResultFormation(searchByPublicHouse) }; case AccommodationType.FromUniversity: var searchByFromUniversity = _context.Employee .Include(x => x.PositionEmployees.IdSubdivisionNavigation.InverseIdSubordinateNavigation) .Include(x => x.PrivateHouseEmployees) .Where(x => x.PrivateHouseEmployees.AsQueryable().Any(t => t.DateReceiving != null)); return new ActualResult <IEnumerable <ResultSearchDTO> > { Result = ResultFormation(searchByFromUniversity) }; default: return new ActualResult <IEnumerable <ResultSearchDTO> >(); } })); } catch (Exception exception) { return(new ActualResult <IEnumerable <ResultSearchDTO> >(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public ActualResult <string> GetHashIdEmployee(string hashId, ReferenceParentType type) { try { long?result; var id = _hashIdUtilities.DecryptLong(hashId); switch (type) { case ReferenceParentType.Family: result = _context.Family.FirstOrDefault(x => x.Id == id)?.IdEmployee; break; case ReferenceParentType.Children: result = _context.Children.FirstOrDefault(x => x.Id == id)?.IdEmployee; break; case ReferenceParentType.GrandChildren: result = _context.GrandChildren.FirstOrDefault(x => x.Id == id)?.IdEmployee; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } if (result != null) { var idEmployee = _hashIdUtilities.EncryptLong(result.Value); return(new ActualResult <string> { Result = idEmployee }); } return(new ActualResult <string>(Errors.EmployeeDeleted)); } catch (Exception exception) { return(new ActualResult <string>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <WellnessFamilyDTO> > GetAsync(string hashId) { try { var id = HashHelper.DecryptLong(hashId); var wellness = await _context.EventFamily .Include(x => x.IdEventNavigation) .FirstOrDefaultAsync(x => x.Id == id); if (wellness == null) { return(new ActualResult <WellnessFamilyDTO>(Errors.TupleDeleted)); } var result = _mapper.Map <WellnessFamilyDTO>(wellness); return(new ActualResult <WellnessFamilyDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <WellnessFamilyDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <ActivityEmployeesDTO> > GetAsync(string hashId) { try { var id = HashHelper.DecryptLong(hashId); var activity = await _context.ActivityEmployees .Include(x => x.IdActivitiesNavigation) .FirstOrDefaultAsync(x => x.Id == id); if (activity == null) { return(new ActualResult <ActivityEmployeesDTO>(Errors.TupleDeleted)); } var result = _mapper.Map <ActivityEmployeesDTO>(activity); return(new ActualResult <ActivityEmployeesDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <ActivityEmployeesDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }
public async Task <ActualResult <PrivilegeEmployeesDTO> > GetAsync(string hashIdEmployee) { try { var id = HashHelper.DecryptLong(hashIdEmployee); var privilege = await _context.PrivilegeEmployees .Include(x => x.IdPrivilegesNavigation) .FirstOrDefaultAsync(x => x.IdEmployee == id); if (privilege == null) { return(new ActualResult <PrivilegeEmployeesDTO>()); } var result = _mapper.Map <PrivilegeEmployeesDTO>(privilege); return(new ActualResult <PrivilegeEmployeesDTO> { Result = result }); } catch (Exception exception) { return(new ActualResult <PrivilegeEmployeesDTO>(DescriptionExceptionHelper.GetDescriptionError(exception))); } }