public IResult <IEmployeeDetailsReturn> GetEmployeeDetailsByEmployeeKey(string employeeKeyValue) { var employeeKeyResult = KeyParserHelper.ParseResult <IEmployeeKey>(employeeKeyValue); if (!employeeKeyResult.Success) { return(employeeKeyResult.ConvertTo <IEmployeeDetailsReturn>()); } var employeeKey = new EmployeeKey(employeeKeyResult.ResultingObject); var employee = _coreUnitOfWork.EmployeesRepository.FindByKey(employeeKey); if (employee == null) { return(new InvalidResult <IEmployeeDetailsReturn>(null, string.Format(UserMessages.EmployeeByKeyNotFound, employeeKeyValue))); } return(new SuccessResult <IEmployeeDetailsReturn>(new EmployeeDetailsReturn { EmployeeKey = new EmployeeKey(employee).KeyValue, DisplayName = employee.DisplayName, UserName = employee.UserName, EmailAddress = employee.EmailAddress, IsActive = employee.IsActive, Claims = ClaimsSerializationHelper.Deserialize(employee.Claims) })); }
private SerializablePackSchedule(PackSchedule packSchedule) { PkgID = null; var productCode = packSchedule.PackagingProduct.Product.ProductCode; if (!string.IsNullOrEmpty(productCode)) { int result; if (int.TryParse(productCode, out result)) { PkgID = result; } } EmployeeKey = new EmployeeKey(packSchedule); TimeStamp = packSchedule.TimeStamp; TargetParameters = new BatchTargetParameters(packSchedule.DefaultBatchTargetParameters); Batches = packSchedule.ProductionBatches.Select(b => new Batch { LotKey = new LotKey(b), EmployeeKey = new EmployeeKey(b), TimeStamp = b.TimeStamp, TargetParameters = new BatchTargetParameters(b.TargetParameters), PickedInventory = new PickedInventory { EmployeeKey = new EmployeeKey(b.Production.PickedInventory), TimeStamp = b.Production.PickedInventory.TimeStamp } }).ToList(); }
public void UpdateEmployeeTest() { // Arrange var employee = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Employee>(); var employeeKey = new EmployeeKey(employee); var fixture = new Fixture(); var input = fixture .Build <UpdateEmployeeParameters>() .With(m => m.EmployeeKey, employeeKey.KeyValue) .With(m => m.Claims, new Dictionary <string, string>() { { "1", "one" }, { "2", "two" }, { "3", "three" }, }) .CreateAnonymous(); input.DisplayName = input.DisplayName.Substring(0, 15); input.UserName = input.UserName.Substring(0, 15); // Act var result = Service.UpdateEmployee(input); // Assert result.AssertSuccess(); }
public IResult UpdateEmployee(IUpdateEmployeeParameters values) { var parseKeyResult = KeyParserHelper.ParseResult <IEmployeeKey>(values.EmployeeKey); if (!parseKeyResult.Success) { return(parseKeyResult); } var employeeKey = new EmployeeKey(parseKeyResult.ResultingObject); var employee = _coreUnitOfWork.EmployeesRepository.FindByKey(employeeKey); if (employee == null) { return(new InvalidResult(string.Format(UserMessages.EmployeeByKeyNotFound, employeeKey))); } employee.DisplayName = values.DisplayName; employee.EmailAddress = values.EmailAddress; employee.IsActive = values.IsActive; employee.UserName = values.UserName; employee.Claims = ClaimsSerializationHelper.Serialize(values.Claims); _coreUnitOfWork.Commit(); return(new SuccessResult("Employee updated successfully.")); }
public string EncodeForCookie() { var sb = new StringBuilder(); sb.Append(EmployeeKey.ToString("N")); foreach (var lineItem in _lineItems) { sb.AppendFormat(",{0},{1}", lineItem.SelectedItem, lineItem.NumItems); } return(sb.ToString()); }
public List <CustomerProductAttributeRange> ToDataModels(IChileProductKey chileProduct, ICompanyKey customer) { var employeeKeyParser = new EmployeeKey(); var attributeNameKeyParser = new AttributeNameKey(); return(AttributeRanges.Select(r => new CustomerProductAttributeRange { EmployeeId = employeeKeyParser.Parse(r.EmployeeKey).EmployeeKey_Id, TimeStamp = r.TimeStamp, CustomerId = customer.CompanyKey_Id, ChileProductId = chileProduct.ChileProductKey_ProductId, AttributeShortName = attributeNameKeyParser.Parse(r.AttributeNameKey).AttributeNameKey_ShortName, Active = r.Active, RangeMin = r.RangeMin, RangeMax = r.RangeMax }).ToList()); }
private static Dictionary <int, Tuple <DateTime, int> > GetEmployeeIdentifiableByLot(PackScheduleDTO packSchedule) { if (packSchedule == null || string.IsNullOrWhiteSpace(packSchedule.Serialized)) { return(new Dictionary <int, Tuple <DateTime, int> >()); } try { var lotKeyParser = new LotKey(); var employeeKey = new EmployeeKey(); return(SerializablePackSchedule.Deserialize(packSchedule.Serialized).Batches.ToDictionary(b => { var lotKey = lotKeyParser.Parse(b.LotKey); return LotNumberBuilder.BuildLotNumber(lotKey).LotNumber; }, b => new Tuple <DateTime, int>(b.TimeStamp, employeeKey.Parse(b.EmployeeKey).EmployeeKey_Id))); } catch (Exception ex) { throw new Exception("Error parsing PackSchedule deserialized data.", ex); } }
public static bool DeserializeIntoPackSchedule(PackSchedule packSchedule, string serializedPackSchedule, out int?pkgID) { pkgID = null; var deserialized = Deserialize(serializedPackSchedule); if (deserialized == null) { return(false); } var employeeKeyParser = new EmployeeKey(); var lotKeyParser = new LotKey(); pkgID = deserialized.PkgID; IEmployeeKey employeeKey; if (employeeKeyParser.TryParse(deserialized.EmployeeKey, out employeeKey)) { packSchedule.EmployeeId = employeeKey.EmployeeKey_Id; } packSchedule.TimeStamp = deserialized.TimeStamp; packSchedule.DefaultBatchTargetParameters = new ProductionBatchTargetParameters(deserialized.TargetParameters); packSchedule.ProductionBatches = deserialized.Batches.Select(b => { var lotKey = lotKeyParser.Parse(b.LotKey); var batchEmployeeKey = employeeKeyParser.Parse(b.EmployeeKey); var pickedEmployeeKey = employeeKeyParser.Parse(b.PickedInventory.EmployeeKey); var productionBatch = new ProductionBatch { EmployeeId = batchEmployeeKey.EmployeeKey_Id, TimeStamp = b.TimeStamp, LotDateCreated = lotKey.LotKey_DateCreated, LotDateSequence = lotKey.LotKey_DateSequence, LotTypeId = lotKey.LotKey_LotTypeId, PackScheduleDateCreated = packSchedule.DateCreated, PackScheduleSequence = packSchedule.SequentialNumber, ProductionHasBeenCompleted = false, TargetParameters = new ProductionBatchTargetParameters(b.TargetParameters), Production = new ChileLotProduction { EmployeeId = batchEmployeeKey.EmployeeKey_Id, TimeStamp = b.TimeStamp, LotDateCreated = lotKey.LotKey_DateCreated, LotDateSequence = lotKey.LotKey_DateSequence, LotTypeId = lotKey.LotKey_LotTypeId, ProductionType = ProductionType.ProductionBatch, PickedInventory = new Models.PickedInventory { EmployeeId = pickedEmployeeKey.EmployeeKey_Id, TimeStamp = b.PickedInventory.TimeStamp, PickedReason = PickedReason.Production, Archived = false, Items = new List <PickedInventoryItem>() } } }; return(productionBatch); }).ToList(); return(true); }
public SerializableNote(Note note) { EmployeeKey = new EmployeeKey(note); TimeStamp = note.TimeStamp; Text = note.Text; }
public static bool UpdateLot(Lot newLot, SerializableLot deserialized, bool tested, out List <LotAttributeDefect> attributeDefects) { if (deserialized == null) { newLot.Attributes = new List <LotAttribute>(); newLot.LotDefects = new List <LotDefect>(); attributeDefects = new List <LotAttributeDefect>(); return(false); } if (deserialized.LotIdentifiable != null) { newLot.EmployeeId = deserialized.LotIdentifiable.EmployeeKey.EmployeeKeyId; newLot.TimeStamp = deserialized.LotIdentifiable.TimeStamp; } var newAttributeDefects = new List <LotAttributeDefect>(); var attributeNameKeyParser = new AttributeNameKey(); var employeeKeyParser = new EmployeeKey(); newLot.Hold = deserialized.HoldType; newLot.HoldDescription = deserialized.HoldDescription; newLot.Attributes = deserialized.Attributes.Select(a => { var nameKey = attributeNameKeyParser.Parse(a.NameKey); var employeeKey = employeeKeyParser.Parse(a.EmployeeKey); return(new LotAttribute { Lot = newLot, TimeStamp = a.TimeStamp, EmployeeId = employeeKey.EmployeeKey_Id, LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, AttributeShortName = nameKey.AttributeNameKey_ShortName, AttributeValue = a.Value, AttributeDate = a.DateTested.Date, Computed = a.Computed ?? !tested }); }).ToList(); var defectId = 0; newLot.LotDefects = deserialized.Defects.Select(d => { DefectTypeEnum defectType; if (!DefectTypeEnum.TryParse(d.DefectType, out defectType)) { throw new Exception(string.Format("Could not parse DefectTypeEnum[{0}]", d.DefectType)); } var resolutionType = default(ResolutionTypeEnum); if (d.DefectResolution != null) { if (!ResolutionTypeEnum.TryParse(d.DefectResolution.ResolutionType, out resolutionType)) { throw new Exception(string.Format("Could not parse ResolutionTypeEnum[{0}]", d.DefectResolution.ResolutionType)); } } defectId += 1; var defect = new LotDefect { LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, DefectId = defectId, DefectType = defectType, Description = d.Description, Resolution = d.DefectResolution == null ? null : new LotDefectResolution { EmployeeId = employeeKeyParser.Parse(d.DefectResolution.EmployeeKey).EmployeeKey_Id, TimeStamp = d.DefectResolution.TimeStamp, LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, DefectId = defectId, ResolutionType = resolutionType, Description = d.DefectResolution.Description, } }; if (d.AttributeDefect != null) { var nameKey = attributeNameKeyParser.Parse(d.AttributeDefect.NameKey); newAttributeDefects.Add(new LotAttributeDefect { LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, DefectId = defectId, AttributeShortName = nameKey.AttributeNameKey_ShortName, OriginalAttributeValue = d.AttributeDefect.Value, OriginalAttributeMinLimit = d.AttributeDefect.Min, OriginalAttributeMaxLimit = d.AttributeDefect.Max, LotDefect = defect }); } return(defect); }).ToList(); attributeDefects = newAttributeDefects; return(true); }
private SerializableBatchInstruction(Note note) { TimeStamp = note.TimeStamp; EmployeeKey = new EmployeeKey(note); }