public static IssueGraph MakeIssueGraph(IUnitOfWork uow, EmployeeCard employee, ProtectionTools protectionTools, EmployeeIssueOperation[] unsavedOprarations = null) { if (MakeIssueGraphTestGap != null) { return(MakeIssueGraphTestGap(employee, protectionTools)); } var matchedProtectionTools = protectionTools.MatchedProtectionTools; var issues = uow.Session.QueryOver <EmployeeIssueOperation>() .Where(x => x.Employee.Id == employee.Id) .Where(x => x.ProtectionTools.Id.IsIn(matchedProtectionTools.Select(n => n.Id).ToArray())) .OrderBy(x => x.OperationTime).Asc .List(); if (unsavedOprarations != null) { foreach (var operation in unsavedOprarations) { if (!issues.Any(x => x.IsSame(operation))) { issues.Add(operation); } } } return(new IssueGraph(issues)); }
public EmployeeCard Create(EmployeeCard EmployeeCard) { if (context.EmployeeCards.Where(x => x.Identifier != null && x.Identifier == EmployeeCard.Identifier).Count() == 0) { EmployeeCard.Id = 0; EmployeeCard.Active = true; EmployeeCard.UpdatedAt = DateTime.Now; EmployeeCard.CreatedAt = DateTime.Now; context.EmployeeCards.Add(EmployeeCard); return(EmployeeCard); } else { // Load item that will be updated EmployeeCard dbEntry = context.EmployeeCards .FirstOrDefault(x => x.Identifier == EmployeeCard.Identifier && x.Active == true); if (dbEntry != null) { dbEntry.CompanyId = EmployeeCard.CompanyId ?? null; dbEntry.CreatedById = EmployeeCard.CreatedById ?? null; // Set properties dbEntry.CardDate = EmployeeCard.CardDate; dbEntry.Description = EmployeeCard.Description; dbEntry.PlusMinus = EmployeeCard.PlusMinus; dbEntry.ItemStatus = EmployeeCard.ItemStatus; // Set timestamp dbEntry.UpdatedAt = DateTime.Now; } return(dbEntry); } }
public void GetReferencedDocuments_WriteOffTest() { var interactive = Substitute.For <IInteractiveQuestion>(); interactive.Question(string.Empty).ReturnsForAnyArgs(true); var baseParameters = Substitute.For <BaseParameters>(); using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { var warehouse = new Warehouse(); uow.Save(warehouse); var nomenclatureType = new ItemsType { Name = "Тестовый тип номенклатуры" }; uow.Save(nomenclatureType); var nomenclature = new Nomenclature { Type = nomenclatureType }; uow.Save(nomenclature); var employee = new EmployeeCard(); uow.Save(employee); var expense = new Expense { Date = new DateTime(2021, 9, 10), Employee = employee, Operation = ExpenseOperations.Employee, Warehouse = warehouse, }; var size = new Size(); var height = new Size(); uow.Save(size); uow.Save(height); var stockPosition = new StockPosition(nomenclature, 0, size, height); var item = expense.AddItem(stockPosition, 10); expense.UpdateOperations(uow, baseParameters, interactive); uow.Save(expense); //Списываем 3 штуки var writeoff = new Writeoff() { Date = new DateTime(2021, 9, 11), }; var writeoffItem = writeoff.AddItem(item.EmployeeIssueOperation, 2); writeoff.UpdateOperations(uow); uow.Save(writeoff); uow.Commit(); var repository = new EmployeeIssueRepository(uow); var result = repository.GetReferencedDocuments(writeoffItem.EmployeeWriteoffOperation.Id); Assert.That(result.First().DocumentType, Is.EqualTo(StokDocumentType.WriteoffDoc)); Assert.That(result.First().DocumentId, Is.EqualTo(writeoff.Id)); Assert.That(result.First().ItemId, Is.EqualTo(writeoffItem.Id)); } }
public void EmployeesLoad_osmbtDepartments() { NewSessionWithSameDB(); var navigation = Substitute.For <INavigationManager>(); var interactive = Substitute.For <IInteractiveMessage>(); var progressStep = Substitute.For <IProgressBarDisplayable>(); var progressInterceptor = Substitute.For <ProgressInterceptor>(); var dataparser = new DataParserEmployee(new PersonNames(), new SizeService(), new PhoneFormatter(PhoneFormat.RussiaOnlyHyphenated)); var setting = new SettingsMatchEmployeesViewModel(); //Так же проверяем что табельные номера вида 00002 превратятся в "2" setting.ConvertPersonnelNumber = true; var model = new ImportModelEmployee(dataparser, setting); using (var rootUow = UnitOfWorkFactory.CreateWithoutRoot()) { var existEmployee = new EmployeeCard { PersonnelNumber = "5213", LastName = "Старая фамилия", FirstName = "Старое имя", Comment = "Старый комментарий" }; rootUow.Save(existEmployee); rootUow.Commit(); using (var employeesLoad = new ExcelImportViewModel(model, UnitOfWorkFactory, navigation, interactive, progressInterceptor)) { var uow = employeesLoad.UoW; var employeesold = uow.GetAll <EmployeeCard>().ToList(); Assert.That(employeesold.Count, Is.EqualTo(1)); employeesLoad.ProgressStep = progressStep; employeesLoad.FileName = "Samples/Excel/osmbt.xls"; Assert.That(employeesLoad.Sheets.Count, Is.GreaterThan(0)); employeesLoad.SelectedSheet = employeesLoad.Sheets.First(); Assert.That(employeesLoad.SensitiveSecondStepButton, Is.True, "Кнопка второго шага должна быть доступна"); employeesLoad.SecondStep(); Assert.That(employeesLoad.SensitiveThirdStepButton, Is.True, "Кнопка третьего шага должна быть доступна"); employeesLoad.ThirdStep(); Assert.That(employeesLoad.SensitiveSaveButton, Is.True, "Кнопка сохранить должна быть доступна"); employeesLoad.Save(); var employees = uow.GetAll <EmployeeCard>().ToList(); Assert.That(employees.Count, Is.EqualTo(2)); var artem = employees.First(x => x.PersonnelNumber == "5213"); Assert.That(artem.FirstName, Is.EqualTo("Артем")); Assert.That(artem.LastName, Is.EqualTo("Беляев")); Assert.That(artem.Comment, Is.EqualTo("Старый комментарий")); //Фамилия и имя заменились, комментарий остался старым. Assert.That(artem.Subdivision.Name, Is.EqualTo("500100 Цех керамического кирпича")); Assert.That(artem.Department.Name, Is.EqualTo("Участок Е1 Бригада 7 (Е1)")); //Проверяем что не дублируем должности и подразделения. var igor = employees.First(x => x.PersonnelNumber == "4103"); Assert.That(igor.Subdivision.Name, Is.EqualTo("500100 Цех керамического кирпича")); Assert.That(igor.Post.Name, Is.EqualTo("Заведующий хозяйством")); Assert.That(igor.Department.Name, Is.EqualTo("Участок 500100")); } } }
private bool СompareFio(SheetRowEmployee x, EmployeeCard employee, List <ImportedColumn <DataTypeEmployee> > columns) { var fio = GetFIO(x, columns); return(String.Equals(fio.LastName, employee.LastName, StringComparison.CurrentCultureIgnoreCase) && String.Equals(fio.FirstName, employee.FirstName, StringComparison.CurrentCultureIgnoreCase) && (fio.Patronymic == null || String.Equals(fio.Patronymic, employee.Patronymic, StringComparison.CurrentCultureIgnoreCase))); }
public void UpdateWorkwearItems_MergeTwoNorms_ConditionCase() { var employee = new EmployeeCard(); var protectionTools = Substitute.For <ProtectionTools>(); var protectionTools2 = Substitute.For <ProtectionTools>(); var protectionTools3 = Substitute.For <ProtectionTools>(); var failCondition = Substitute.For <NormCondition>(); failCondition.MatchesForEmployee(employee).Returns(false); var norm1 = Substitute.For <Norm>(); var norm1item1 = Substitute.For <NormItem>(); norm1item1.ProtectionTools.Returns(protectionTools); norm1item1.NormCondition.ReturnsNull(); var norm1item2 = Substitute.For <NormItem>(); norm1item2.ProtectionTools.Returns(protectionTools2); norm1item2.AmountPerYear.Returns(5); norm1item2.NormCondition.Returns(failCondition); norm1.Items.Returns(new List <NormItem> { norm1item1, norm1item2 }); var norm2 = Substitute.For <Norm>(); var norm2item1 = Substitute.For <NormItem>(); norm2item1.ProtectionTools.Returns(protectionTools2); norm2item1.AmountPerYear.Returns(2); norm2item1.NormCondition.ReturnsNull(); var norm2item2 = Substitute.For <NormItem>(); norm2item2.ProtectionTools.Returns(protectionTools3); norm2item2.NormCondition.ReturnsNull(); norm2.Items.Returns(new List <NormItem> { norm2item1, norm2item2 }); employee.AddUsedNorm(norm1); employee.AddUsedNorm(norm2); //Происходит автоматически //employee.UpdateWorkwearItems(); Assert.That(employee.WorkwearItems, Has.Count.EqualTo(3)); var item1 = employee.WorkwearItems.First(x => x.ProtectionTools == protectionTools); Assert.That(item1.ActiveNormItem, Is.EqualTo(norm1item1)); var item2 = employee.WorkwearItems.First(x => x.ProtectionTools == protectionTools2); Assert.That(item2.ActiveNormItem, Is.EqualTo(norm2item1)); var item3 = employee.WorkwearItems.First(x => x.ProtectionTools == protectionTools3); Assert.That(item3.ActiveNormItem, Is.EqualTo(norm2item2)); }
public void MatcheStockPosition_RangeGrowthInEmployeeSize() { var employee = new EmployeeCard { Sex = Sex.M }; var sizeType = new SizeType { CategorySizeType = CategorySizeType.Size }; var heightType = new SizeType { CategorySizeType = CategorySizeType.Height }; var size52 = new Size { Name = "52", SizeType = sizeType, UseInEmployee = true }; var height170And176 = new Size { Name = "170-176", SizeType = heightType, UseInEmployee = true }; var height170 = new Size { Name = "170", SizeType = heightType, UseInEmployee = true, SuitableSizes = new List <Size> { height170And176 } }; employee.Sizes.Add(new EmployeeSize { Size = height170And176, SizeType = heightType }); employee.Sizes.Add(new EmployeeSize { Size = size52, SizeType = sizeType }); var itemType = Substitute.For <ItemsType>(); itemType.Category.Returns(ItemTypeCategory.wear); var nomenclature = Substitute.For <Nomenclature>(); nomenclature.Id.Returns(25); nomenclature.Type.Returns(itemType); nomenclature.MatchingEmployeeSex(Sex.M).Returns(true); var protectionTools = Substitute.For <ProtectionTools>(); protectionTools.MatchedNomenclatures.Returns(new[] { nomenclature }); var normItem = Substitute.For <NormItem>(); normItem.ProtectionTools.Returns(protectionTools); var employeeItem = new EmployeeCardItem(employee, normItem); var stockPosition = new StockPosition(nomenclature, 0, size52, height170); var result = employeeItem.MatcheStockPosition(stockPosition); Assert.That(result, Is.True); }
public static List <EmployeeCardViewModel> ConvertToEmployeeCardViewModelList(this IEnumerable <EmployeeCard> employeeCards) { List <EmployeeCardViewModel> EmployeeCardViewModels = new List <EmployeeCardViewModel>(); foreach (EmployeeCard EmployeeCard in employeeCards) { EmployeeCardViewModels.Add(EmployeeCard.ConvertToEmployeeCardViewModel()); } return(EmployeeCardViewModels); }
public EmployeeIssueGraphViewModel( INavigationManager navigation, IUnitOfWorkFactory factory, EmployeeCard employee, ProtectionTools protectionTools) : base(navigation) { using (var unitOfWork = factory.CreateWithoutRoot()) Intervals = IssueGraph.MakeIssueGraph(unitOfWork, employee, protectionTools).Intervals; Title = $"Хронология {employee.ShortName} - {protectionTools.Name}"; }
public void HandleDelete_CanDeleteEmployeeTest() { var ask = Substitute.For <IInteractiveQuestion>(); ask.Question(string.Empty).ReturnsForAnyArgs(true); using (var uow = UnitOfWorkFactory.CreateWithoutRoot("Тест на обработку удаления сотрудника")) { BuisnessLogicGlobalEventHandler.Init(ask, UnitOfWorkFactory); var nomenclatureType = new ItemsType(); nomenclatureType.Name = "Тестовый тип номенклатуры"; uow.Save(nomenclatureType); var nomenclature = new Nomenclature(); nomenclature.Type = nomenclatureType; uow.Save(nomenclature); var protectionTools = new ProtectionTools(); protectionTools.Name = "СИЗ для тестирования"; protectionTools.AddNomeclature(nomenclature); uow.Save(protectionTools); var norm = new Norm(); var normItem = norm.AddItem(protectionTools); normItem.Amount = 1; normItem.NormPeriod = NormPeriodType.Month; normItem.PeriodCount = 2; uow.Save(norm); var employee = new EmployeeCard(); uow.Save(employee); var warehouseOperation = new WarehouseOperation(); var expenseOp = new EmployeeIssueOperation(); expenseOp.OperationTime = warehouseOperation.OperationTime = new DateTime(2019, 1, 1); expenseOp.ExpiryByNorm = new DateTime(2019, 4, 1); expenseOp.ProtectionTools = protectionTools; expenseOp.Employee = employee; expenseOp.Nomenclature = warehouseOperation.Nomenclature = nomenclature; expenseOp.NormItem = normItem; warehouseOperation.Amount = expenseOp.Issued = 1; expenseOp.WarehouseOperation = warehouseOperation; uow.Save(nomenclature); uow.Save(normItem); uow.Save(warehouseOperation); uow.Save(expenseOp); uow.Commit(); //FIXME Временно чтобы переделака не вызвала конфликт мержа в 2.4 Configure.ConfigureDeletion(); var deletion = new DeleteCore(DeleteConfig.Main, uow); deletion.PrepareDeletion(typeof(EmployeeCard), employee.Id, CancellationToken.None); deletion.RunDeletion(CancellationToken.None); } }
/// <summary> /// Получаем все операции выдачи сотруднику отсортированные в порядке убывания. /// </summary> /// <returns></returns> public IList <EmployeeIssueOperation> AllOperationsForEmployee( EmployeeCard employee, Action <IQueryOver <EmployeeIssueOperation, EmployeeIssueOperation> > makeEager = null, IUnitOfWork uow = null) { var query = (uow ?? RepoUow).Session.QueryOver <EmployeeIssueOperation>() .Where(o => o.Employee == employee); makeEager?.Invoke(query); return(query.OrderBy(x => x.OperationTime).Desc.List()); }
protected override IQueryOver <IssuanceSheet> ItemsQuery(IUnitOfWork uow) { IssuanceSheetJournalNode resultAlias = null; IssuanceSheet issuanceSheetAlias = null; IssuanceSheetItem issuanceSheetItemAlias = null; Organization organizationAlias = null; Subdivision subdivisionAlias = null; EmployeeCard employeeCardAlias = null; var employeesSubquery = QueryOver.Of <IssuanceSheetItem>(() => issuanceSheetItemAlias) .Where(() => issuanceSheetItemAlias.IssuanceSheet.Id == issuanceSheetAlias.Id) .JoinQueryOver(x => x.Employee, () => employeeCardAlias) .Select(CustomProjections .GroupConcat(Projections .Property(() => employeeCardAlias.LastName), useDistinct: true, separator: ", ")); var query = uow.Session.QueryOver <IssuanceSheet>(() => issuanceSheetAlias); if (Filter.StartDate != null) { query.Where(x => x.Date >= Filter.StartDate); } if (Filter.EndDate != null) { query.Where(x => x.Date <= Filter.EndDate); } return(query .Where(GetSearchCriterion( () => issuanceSheetAlias.Id, () => issuanceSheetAlias.Expense.Id, () => issuanceSheetAlias.CollectiveExpense.Id, () => organizationAlias.Name, () => subdivisionAlias.Name, () => subdivisionAlias.Code )) .Left.JoinAlias(s => s.Organization, () => organizationAlias) .Left.JoinAlias(s => s.Subdivision, () => subdivisionAlias) .SelectList((list) => list .Select(x => x.Id).WithAlias(() => resultAlias.Id) .Select(x => x.Date).WithAlias(() => resultAlias.Date) .Select(() => organizationAlias.Name).WithAlias(() => resultAlias.Organigation) .Select(() => subdivisionAlias.Name).WithAlias(() => resultAlias.Subdivision) .Select(() => subdivisionAlias.Code).WithAlias(() => resultAlias.SubdivisionCode) .Select(x => x.Expense.Id).WithAlias(() => resultAlias.DocExpenseId) .Select(x => x.CollectiveExpense.Id).WithAlias(() => resultAlias.DocCollectiveExpenseId) .SelectSubQuery(employeesSubquery).WithAlias(() => resultAlias.Employees) ) .OrderBy(() => issuanceSheetAlias.Date).Desc .ThenBy(() => issuanceSheetAlias.Id).Desc .TransformUsing(Transformers.AliasToBean <IssuanceSheetJournalNode>())); }
public void UpdateView() { CardView.Children.Clear(); foreach (var user in users) { EmployeeCard card = new EmployeeCard(user) { Margin = new Thickness(10) }; CardView.Children.Add(card); } }
public IList <EmployeeIssueOperation> GetOperationsForEmployee( IUnitOfWork uow, EmployeeCard employee, ProtectionTools protectionTools, Action <IQueryOver <EmployeeIssueOperation, EmployeeIssueOperation> > makeEager = null) { var query = uow.Session.QueryOver <EmployeeIssueOperation>() .Where(o => o.Employee == employee) .Where(o => o.ProtectionTools == protectionTools); makeEager?.Invoke(query); return(query.OrderBy(x => x.OperationTime).Asc.List()); }
public EmployeeCard Delete(Guid identifier) { EmployeeCard dbEntry = context.EmployeeCards .Union(context.ChangeTracker.Entries() .Where(x => x.State == EntityState.Added && x.Entity.GetType() == typeof(EmployeeCard)) .Select(x => x.Entity as EmployeeCard)) .FirstOrDefault(x => x.Identifier == identifier && x.Active == true); if (dbEntry != null) { dbEntry.Active = false; dbEntry.UpdatedAt = DateTime.Now; } return(dbEntry); }
private async Task DisplayEmployeeCard(IDialogContext context, EmployeeItem employee) { await context.SendTypingIndicator(); var replyToConversation = context.MakeMessage(); replyToConversation.Attachments = new List <Attachment> (); var card = new EmployeeCard(employee); replyToConversation.Attachments.Add(card.AsAttachment()); await context.PostAsync(replyToConversation); context.Wait(MessageReceived); }
public void MakeIssueGraph_UseManualOperationsTest() { using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { var nomenclatureType = new ItemsType(); nomenclatureType.Name = "Тестовый тип номенклатуры"; uow.Save(nomenclatureType); var nomenclature = new Nomenclature(); nomenclature.Type = nomenclatureType; uow.Save(nomenclature); var protectionTools = new ProtectionTools(); protectionTools.Name = "СИЗ для тестирования"; protectionTools.AddNomeclature(nomenclature); uow.Save(protectionTools); var employee = new EmployeeCard(); uow.Save(employee); //Операция без номеклатуры var manualOp = new EmployeeIssueOperation(); manualOp.OperationTime = new DateTime(2019, 1, 1, 14, 0, 0); manualOp.AutoWriteoffDate = new DateTime(2020, 1, 1); manualOp.Employee = employee; manualOp.ProtectionTools = protectionTools; manualOp.Issued = 1; manualOp.OverrideBefore = true; uow.Save(manualOp); var expenseOp = new EmployeeIssueOperation(); expenseOp.OperationTime = new DateTime(2020, 1, 1, 13, 0, 0); expenseOp.AutoWriteoffDate = new DateTime(2021, 1, 1); expenseOp.Employee = employee; expenseOp.Nomenclature = nomenclature; expenseOp.ProtectionTools = protectionTools; expenseOp.Issued = 1; uow.Save(expenseOp); uow.Commit(); var graph = IssueGraph.MakeIssueGraph(uow, employee, protectionTools); Assert.That(graph.Intervals.Count, Is.EqualTo(3)); var first = graph.OrderedIntervals.First(); Assert.That(first.StartDate, Is.EqualTo(new DateTime(2019, 1, 1))); } }
private async Task DisplayEmployeeCard(IDialogContext context, string employeeId) { await context.SendTypingIndicator(); var employee = employees.Where(x => x.EmployeeKey == long.Parse(employeeId)).First(); var replyToConversation = context.MakeMessage(); replyToConversation.Attachments = new List <Attachment> (); var card = new EmployeeCard(employee); replyToConversation.Attachments.Add(card.AsAttachment()); await context.PostAsync(replyToConversation); context.Wait(MessageReceived); }
public static EmployeeCardViewModel ConvertToEmployeeCardViewModelLite(this EmployeeCard employeeCard) { EmployeeCardViewModel EmployeeCardViewModel = new EmployeeCardViewModel() { Id = employeeCard.Id, Identifier = employeeCard.Identifier, CardDate = employeeCard.CardDate, Description = employeeCard.Description, PlusMinus = employeeCard.PlusMinus, ItemStatus = employeeCard.ItemStatus, IsActive = employeeCard.Active, UpdatedAt = employeeCard.UpdatedAt, CreatedAt = employeeCard.CreatedAt }; return(EmployeeCardViewModel); }
public EmployeeByConstructionSiteResponse Create(EmployeeByConstructionSiteViewModel re) { EmployeeByConstructionSiteResponse response = new EmployeeByConstructionSiteResponse(); try { ConstructionSite constructionSite = unitOfWork.GetConstructionSiteRepository().GetConstructionSite(re.ConstructionSite.Id); Employee employee = unitOfWork.GetEmployeeRepository().GetEmployeeEntity(re.Employee.Id); employee.ConstructionSiteCode = constructionSite.InternalCode; employee.ConstructionSiteName = constructionSite.Name; employee.UpdatedAt = DateTime.Now; EmployeeByConstructionSite addedEmployeeByConstructionSite = unitOfWork.GetEmployeeByConstructionSiteRepository().Create(re.ConvertToEmployeeByConstructionSite()); EmployeeCard ec = new EmployeeCard() { Identifier = Guid.NewGuid(), EmployeeId = re.Employee.Id, CardDate = addedEmployeeByConstructionSite.StartDate, Description = "Radnik " + employee?.Name + " " + employee?.SurName + " je krenuo da radi na gradilištu " + constructionSite?.Name + ". Radnik je na gradilištu od: " + re.StartDate.ToString("dd.MM.yyyy") + " do " + re.EndDate.ToString("dd.MM.yyyy"), PlusMinus = "+", CreatedById = re.CreatedBy?.Id, CompanyId = re.Company?.Id, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }; unitOfWork.GetEmployeeCardRepository().Create(ec); unitOfWork.Save(); response.EmployeeByConstructionSite = addedEmployeeByConstructionSite.ConvertToEmployeeByConstructionSiteViewModel(); response.Success = true; } catch (Exception ex) { response.EmployeeByConstructionSite = new EmployeeByConstructionSiteViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public EmployeeBalanceJournalViewModel( IUnitOfWorkFactory unitOfWorkFactory, IInteractiveService interactiveService, INavigationManager navigation, ILifetimeScope autofacScope, EmployeeCard employeeCard = null) : base(unitOfWorkFactory, interactiveService, navigation) { var dataLoader = new ThreadDataLoader <EmployeeBalanceJournalNode>(unitOfWorkFactory); dataLoader.AddQuery(ItemsQuery); DataLoader = dataLoader; AutofacScope = autofacScope; JournalFilter = Filter = AutofacScope.Resolve <EmployeeBalanceFilterViewModel>( new TypedParameter(typeof(JournalViewModelBase), this)); this.Filter.Employee = employeeCard; Title = employeeCard != null ? $"Числится за сотрудником - {Filter.Employee.Title}" : "Остатки по сотрудникам"; }
public EmployeeByConstructionSiteResponse Delete(EmployeeByConstructionSiteViewModel re) { EmployeeByConstructionSiteResponse response = new EmployeeByConstructionSiteResponse(); try { EmployeeByConstructionSite deletedEmployeeByConstructionSite = unitOfWork.GetEmployeeByConstructionSiteRepository().Delete(re.ConvertToEmployeeByConstructionSite()); Employee employee = unitOfWork.GetEmployeeRepository().GetEmployeeEntity((int)deletedEmployeeByConstructionSite.EmployeeId); ConstructionSite constructionSite = unitOfWork.GetConstructionSiteRepository().GetConstructionSite((int)deletedEmployeeByConstructionSite.ConstructionSiteId); employee.ConstructionSiteCode = ""; employee.ConstructionSiteName = ""; employee.UpdatedAt = DateTime.Now; EmployeeCard ec = new EmployeeCard() { Identifier = Guid.NewGuid(), EmployeeId = deletedEmployeeByConstructionSite.Employee.Id, CardDate = (DateTime)deletedEmployeeByConstructionSite.RealEndDate, Description = "Radnik " + employee?.Name + " " + employee.SurName + " je prestao da radi na gradilištu " + constructionSite?.Name + ". Prestanak je od: " + ((DateTime)deletedEmployeeByConstructionSite.RealEndDate).ToString("dd.MM.yyyy"), CreatedById = deletedEmployeeByConstructionSite.CreatedById, PlusMinus = "-", CompanyId = deletedEmployeeByConstructionSite.CompanyId, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }; unitOfWork.GetEmployeeCardRepository().Create(ec); unitOfWork.Save(); response.EmployeeByConstructionSite = deletedEmployeeByConstructionSite.ConvertToEmployeeByConstructionSiteViewModel(); response.Success = true; } catch (Exception ex) { response.EmployeeByConstructionSite = new EmployeeByConstructionSiteViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public EmployeeByBusinessPartnerResponse Delete(EmployeeByBusinessPartnerViewModel employeeByBysinessPartner) { EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerResponse(); try { EmployeeByBusinessPartner deletedEmployeeByBusinessPartner = unitOfWork.GetEmployeeByBusinessPartnerRepository() .Delete(employeeByBysinessPartner.ConvertToEmployeeByBusinessPartner()); Employee employee = unitOfWork.GetEmployeeRepository().GetEmployee((int)deletedEmployeeByBusinessPartner.EmployeeId); BusinessPartner businessPartner = unitOfWork.GetBusinessPartnerRepository().GetBusinessPartner((int)deletedEmployeeByBusinessPartner.BusinessPartnerId); EmployeeCard ec = new EmployeeCard() { Identifier = Guid.NewGuid(), EmployeeId = deletedEmployeeByBusinessPartner.EmployeeId, CardDate = (DateTime)deletedEmployeeByBusinessPartner.RealEndDate, Description = "Radnik " + employee?.Name + " " + employee?.SurName + " je raskinuo ugovor sa firmom " + businessPartner?.Name + ". Prestanak je od: " + ((DateTime)deletedEmployeeByBusinessPartner.RealEndDate).ToString("dd.MM.yyyy"), PlusMinus = "-", CreatedById = deletedEmployeeByBusinessPartner.CreatedById, CompanyId = deletedEmployeeByBusinessPartner.CompanyId, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }; unitOfWork.GetEmployeeCardRepository().Create(ec); unitOfWork.Save(); response.EmployeeByBusinessPartner = deletedEmployeeByBusinessPartner.ConvertToEmployeeByBusinessPartnerViewModel(); response.Success = true; } catch (Exception ex) { response.EmployeeByBusinessPartner = new EmployeeByBusinessPartnerViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public WriteOffViewModel( IEntityUoWBuilder uowBuilder, IUnitOfWorkFactory unitOfWorkFactory, INavigationManager navigation, SizeService sizeService, EmployeeCard employee = null, Subdivision subdivision = null, IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator) { SizeService = sizeService; NavigationManager = navigation; Entity.ObservableItems.PropertyChanged += CalculateTotal; CalculateTotal(null, null); if (employee != null) { Employee = UoW.GetById <EmployeeCard>(employee.Id); } else if (subdivision != null) { Subdivision = UoW.GetById <Subdivision>(subdivision.Id); } }
public bool MatcheStockPosition_ClothesSex(Sex employeeSex, ClothesSex?clothesSex) { var employee = new EmployeeCard(); employee.Sex = employeeSex; var itemType = Substitute.For <ItemsType>(); var nomenclature = new Nomenclature { Id = 25, Type = itemType, Sex = clothesSex }; var protectionTools = Substitute.For <ProtectionTools>(); protectionTools.MatchedNomenclatures.Returns(new[] { nomenclature }); var normItem = Substitute.For <NormItem>(); normItem.ProtectionTools.Returns(protectionTools); var employeeItem = new EmployeeCardItem(employee, normItem); return(employeeItem.MatcheStockPosition(new StockPosition(nomenclature, 0, null, null))); }
public void MatcheStockPosition_SizeTest() { var employee = new EmployeeCard(); employee.Sex = Sex.M; var sizeType = new SizeType { CategorySizeType = CategorySizeType.Size }; var size = new Size { Name = "52", SizeType = sizeType }; employee.Sizes.Add(new EmployeeSize { Size = size, SizeType = sizeType, Employee = employee }); var itemType = Substitute.For <ItemsType>(); itemType.SizeType.Returns(sizeType); var nomenclature = Substitute.For <Nomenclature>(); nomenclature.Id.Returns(25); nomenclature.Type.Returns(itemType); nomenclature.MatchingEmployeeSex(Sex.M).Returns(true); var protectionTools = Substitute.For <ProtectionTools>(); protectionTools.MatchedNomenclatures.Returns(new[] { nomenclature }); var normItem = Substitute.For <NormItem>(); normItem.ProtectionTools.Returns(protectionTools); var employeeItem = new EmployeeCardItem(employee, normItem); var stockPosition = new StockPosition(nomenclature, 0, size, null); var result = employeeItem.MatcheStockPosition(stockPosition); Assert.That(result, Is.True); }
public EmployeeByBusinessPartnerResponse Create(EmployeeByBusinessPartnerViewModel re) { EmployeeByBusinessPartnerResponse response = new EmployeeByBusinessPartnerResponse(); try { EmployeeByBusinessPartner addedEmployeeByBusinessPartner = unitOfWork.GetEmployeeByBusinessPartnerRepository() .Create(re.ConvertToEmployeeByBusinessPartner()); EmployeeCard ec = new EmployeeCard() { Identifier = Guid.NewGuid(), EmployeeId = re.Employee.Id, CardDate = re.StartDate, Description = "Radnik " + re.Employee?.Name + " " + re.Employee?.SurName + " je sklopio ugovor sa firmom " + re.BusinessPartner?.Name + ". Radnik je u firmi od: " + re.StartDate.ToString("dd.MM.yyyy") + " do " + re.EndDate.ToString("dd.MM.yyyy"), PlusMinus = "+", CreatedById = re.CreatedBy?.Id, CompanyId = re.Company?.Id, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now }; unitOfWork.GetEmployeeCardRepository().Create(ec); unitOfWork.Save(); response.EmployeeByBusinessPartner = addedEmployeeByBusinessPartner.ConvertToEmployeeByBusinessPartnerViewModel(); response.Success = true; } catch (Exception ex) { response.EmployeeByBusinessPartner = new EmployeeByBusinessPartnerViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public async ValueTask <ServiceResult <VerdictDto> > AddVerdict(CreateVerdictDto verdictDto) { if (verdictDto == null || string.IsNullOrEmpty(verdictDto.Name) || !verdictDto.Verdict.HasValue) { return(new ServiceResult <VerdictDto>(false, null)); } var verdict = new EmployeeCard { Name = verdictDto.Name, Age = verdictDto.Age, Verdict = verdictDto.Verdict.Value }; _dbSet.Add(verdict); await _context.SaveChangesAsync(); return(new ServiceResult <VerdictDto>(true, new VerdictDto() { Age = verdict.Age, Name = verdict.Name, Verdict = verdict.Verdict })); }
public void FindChanges( IUnitOfWork uow, IEnumerable <SheetRowEmployee> list, ImportedColumn <DataTypeEmployee>[] meaningfulColumns, IProgressBarDisplayable progress, SettingsMatchEmployeesViewModel settings) { progress.Start(list.Count(), text: "Поиск изменений"); foreach (var row in list) { progress.Add(); if (row.Skipped) { continue; } var employee = row.Employees.FirstOrDefault(); var rowChange = ChangeType.ChangeValue; if (employee == null) { employee = new EmployeeCard { Comment = "Импортирован из Excel", CreatedbyUser = userService?.GetCurrentUser(uow) }; row.Employees.Add(employee); rowChange = ChangeType.NewEntity; } foreach (var column in meaningfulColumns) { MakeChange(settings, employee, row, column, rowChange, uow); } } progress.Close(); }
public static IList <EmployeeRecivedInfo> ItemsBalance(IUnitOfWork uow, EmployeeCard employee, DateTime onDate) { EmployeeRecivedInfo resultAlias = null; EmployeeIssueOperation employeeIssueOperationAlias = null; EmployeeIssueOperation employeeIssueOperationReceivedAlias = null; IProjection projection = Projections.SqlFunction( new SQLFunctionTemplate(NHibernateUtil.Int32, "SUM(IFNULL(?1, 0) - IFNULL(?2, 0))"), NHibernateUtil.Int32, Projections.Property <EmployeeIssueOperation>(x => x.Issued), Projections.Property <EmployeeIssueOperation>(x => x.Returned) ); IProjection projectionIssueDate = Projections.SqlFunction( new SQLFunctionTemplate(NHibernateUtil.Date, "MAX(CASE WHEN ?1 > 0 THEN ?2 END)"), NHibernateUtil.Date, Projections.Property <EmployeeIssueOperation>(x => x.Issued), Projections.Property <EmployeeIssueOperation>(x => x.OperationTime) ); return(uow.Session.QueryOver <EmployeeIssueOperation>(() => employeeIssueOperationAlias) .Left.JoinAlias(x => x.IssuedOperation, () => employeeIssueOperationReceivedAlias) .Where(x => x.Employee == employee) .Where(() => employeeIssueOperationAlias.AutoWriteoffDate == null || employeeIssueOperationAlias.AutoWriteoffDate > onDate) .Where(() => employeeIssueOperationReceivedAlias.AutoWriteoffDate == null || employeeIssueOperationReceivedAlias.AutoWriteoffDate > onDate) .SelectList(list => list .SelectGroup(() => employeeIssueOperationAlias.ProtectionTools.Id).WithAlias(() => resultAlias.ProtectionToolsId) .SelectGroup(() => employeeIssueOperationAlias.NormItem.Id).WithAlias(() => resultAlias.NormRowId) .Select(projectionIssueDate).WithAlias(() => resultAlias.LastReceive) .Select(projection).WithAlias(() => resultAlias.Amount) .Select(() => employeeIssueOperationAlias.Nomenclature.Id).WithAlias(() => resultAlias.NomenclatureId) ) .TransformUsing(Transformers.AliasToBean <EmployeeRecivedInfo>()) .List <EmployeeRecivedInfo>()); }