public void IdenticalSeedBidTest() { Random rand1 = new Random(0); Random rand2 = new Random(0); TECBid bid1 = ModelCreation.TestBid(rand1); TECBid bid2 = ModelCreation.TestBid(rand2); TECEstimator estimator1 = new TECEstimator(bid1, new ChangeWatcher(bid1)); TECEstimator estimator2 = new TECEstimator(bid2, new ChangeWatcher(bid2)); Assert.AreEqual(estimator1.TotalCost, estimator2.TotalCost); }
public void GetAllSubScopeTest() { Random rand = new Random(0); TECBid bid = ModelCreation.TestBid(rand); TECSystem system = ModelCreation.TestSystem(bid.Catalogs, rand); var allSubScope = system.GetAllSubScope(); foreach (var subScope in system.Equipment.SelectMany(e => e.SubScope)) { Assert.IsTrue(allSubScope.Contains(subScope)); } }
public void AddElectricalMiscToBid() { //Arrange TECMisc misc = ModelCreation.TestMisc(bid.Catalogs, rand, CostType.Electrical); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act bid.MiscCosts.Add(misc); //Assert AssertMaterialVMMatchesCostBatch(matVM, misc.CostBatch); }
public void CatalogCopyTest() { Random rand = new Random(0); TECBid bid = ModelCreation.TestBid(rand); TECIOModule module = ModelCreation.TestIOModule(bid.Catalogs, rand); var copy = module.CatalogCopy(); Assert.AreEqual(module.Name, copy.Name); Assert.AreEqual(module.Manufacturer, copy.Manufacturer); Assert.AreEqual(module.Cost, copy.Cost); Assert.AreEqual(module.IO.Count, copy.IO.Count); }
public void IsTemplateObjectTest() { Random rand = new Random(0); TECTemplates templates = ModelCreation.TestTemplates(rand); var scopeTemplates = templates.Templates; Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.SubScopeTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.EquipmentTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.SystemTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.ControllerTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.PanelTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.MiscCostTemplates.First())); Assert.IsTrue(templates.IsTemplateObject(scopeTemplates.Parameters.First())); }
public static void ClassInitialize(TestContext TestContext) { rand = new Random(0); //Arrange expectedTemplates = ModelCreation.TestTemplates(rand); ModelCreation.AddSyncronizerItems(expectedTemplates); expectedSystem = expectedTemplates.Templates.SystemTemplates.First(); expectedEquipment = expectedTemplates.Templates.EquipmentTemplates.First(); expectedSubScope = expectedTemplates.Templates.SubScopeTemplates.First(); expectedDevice = expectedTemplates.Catalogs.Devices.First(); expectedManufacturer = expectedTemplates.Catalogs.Manufacturers.First(); expectedTag = expectedTemplates.Catalogs.Tags[0]; expectedController = (TECProvidedController)expectedTemplates.Templates.ControllerTemplates.First(sys => sys is TECProvidedController); expectedAssociatedCost = expectedTemplates.Catalogs.AssociatedCosts[0]; expectedConnectionType = expectedTemplates.Catalogs.ConnectionTypes[0]; expectedConduitType = expectedTemplates.Catalogs.ConduitTypes[0]; path = Path.GetTempFileName(); //Act DatabaseManager <TECTemplates> manager = new DatabaseManager <TECTemplates>(path); bool success = manager.New(expectedTemplates); Assert.IsTrue(success, "New method in DatabaseManager returned false."); actualTemplates = manager.Load(); if (actualTemplates.Templates.SystemTemplates.Count == 0) { string failDirectory = Path.GetTempPath() + "Estimating Tools\\"; Directory.CreateDirectory(failDirectory); string failPath = failDirectory + "SaveNewTemplatesTestFailed.tdb"; if (File.Exists(failPath)) { File.Delete(failPath); } File.Copy(path, failPath); Assert.Fail(string.Format("No systems loaded into templates. File saved at: {0}", failPath)); } actualSystem = actualTemplates.Templates.SystemTemplates.First(x => x.Guid == expectedSystem.Guid); actualEquipment = actualTemplates.Templates.EquipmentTemplates.First(x => x.Guid == expectedEquipment.Guid); actualSubScope = actualTemplates.Templates.SubScopeTemplates.First(x => x.Guid == expectedSubScope.Guid); actualDevice = actualTemplates.Catalogs.Devices.First(x => x.Guid == expectedDevice.Guid); actualManufacturer = actualTemplates.Catalogs.Manufacturers.First(x => x.Guid == expectedManufacturer.Guid); actualTag = actualTemplates.Catalogs.Tags.First(x => x.Guid == expectedTag.Guid); actualController = actualTemplates.Templates.ControllerTemplates.First(x => x.Guid == expectedController.Guid) as TECProvidedController; actualAssociatedCost = actualTemplates.Catalogs.AssociatedCosts.First(x => x.Guid == expectedAssociatedCost.Guid); actualConnectionType = actualTemplates.Catalogs.ConnectionTypes.First(x => x.Guid == expectedConnectionType.Guid); actualConduitType = actualTemplates.Catalogs.ConduitTypes.First(x => x.Guid == expectedConduitType.Guid); }
public void DragDropCopyTest() { Random rand = new Random(0); TECBid bid = ModelCreation.TestBid(rand); TECEquipment equip = ModelCreation.TestEquipment(bid.Catalogs, rand); bid.Systems.First().Equipment.Add(equip); TECEquipment copy = equip.DropData() as TECEquipment; Assert.AreEqual(equip.Name, copy.Name); Assert.AreEqual(equip.SubScope.Count, copy.SubScope.Count); Assert.IsTrue(equip.CostBatch.CostsEqual(copy.CostBatch)); }
public void CatalogCopyTest() { Random rand = new Random(0); TECCatalogs catalogs = ModelCreation.TestCatalogs(rand); TECValve valve = ModelCreation.TestValve(catalogs, rand); var copy = valve.CatalogCopy(); Assert.AreNotEqual(valve.Guid, copy.Guid); Assert.AreEqual(valve.Name, copy.Name); Assert.AreEqual(valve.Description, copy.Description); Assert.AreEqual(valve.Price, copy.Price); Assert.AreEqual(valve.Manufacturer, copy.Manufacturer); Assert.AreEqual(valve.Actuator, copy.Actuator); }
public void Controller_AddSubScope() { TECCatalogs catalogs = ModelCreation.TestCatalogs(rand); TECController controller = ModelCreation.TestProvidedController(catalogs, rand); TECSubScope subScope = new TECSubScope(); TECDevice dev = catalogs.Devices.First(); subScope.Devices.Add(dev); controller.Connect(subScope, subScope.AvailableProtocols.First(y => controller.AvailableProtocols.Contains(y))); Assert.AreEqual(1, controller.ChildrenConnections.Count, "Connection not added to controller"); Assert.AreNotEqual(null, subScope.Connection, "Connection not added to subscope"); }
public void CopyControllerTest() { Random rand = new Random(0); var catalogs = ModelCreation.TestCatalogs(rand); var controller = new TECFBOController(catalogs); controller.Name = "test"; var copy = controller.CopyController(new Dictionary <Guid, Guid>()); Assert.IsTrue(controller.IO.Protocols.SequenceEqual(copy.IO.Protocols)); Assert.AreEqual(controller.Name, copy.Name); }
private void AfterDeserialization() { // BackwardsCompatibility3.4 #region Backwards compatible code, remove with 3.5 #region LossFunction // parameter type has been changed var lossFunctionParam = Parameters[LossFunctionParameterName] as ConstrainedValueParameter <StringValue>; if (lossFunctionParam != null) { Parameters.Remove(LossFunctionParameterName); var selectedValue = lossFunctionParam.Value; // to be restored below var lossFunctions = ApplicationManager.Manager.GetInstances <ILossFunction>(); Parameters.Add(new ConstrainedValueParameter <ILossFunction>(LossFunctionParameterName, "The loss function", new ItemSet <ILossFunction>(lossFunctions))); // try to restore selected value var selectedLossFunction = LossFunctionParameter.ValidValues.FirstOrDefault(f => f.ToString() == selectedValue.Value); if (selectedLossFunction != null) { LossFunctionParameter.Value = selectedLossFunction; } else { LossFunctionParameter.Value = LossFunctionParameter.ValidValues.First(f => f.ToString().Contains("Squared")); // default: SE } } #endregion #region CreateSolution // parameter type has been changed if (Parameters.ContainsKey("CreateSolution")) { var createSolutionParam = Parameters["CreateSolution"] as FixedValueParameter <BoolValue>; Parameters.Remove(createSolutionParam); ModelCreation value = createSolutionParam.Value.Value ? ModelCreation.Model : ModelCreation.QualityOnly; Parameters.Add(new FixedValueParameter <EnumValue <ModelCreation> >(ModelCreationParameterName, "Defines the results produced at the end of the run (Surrogate => Less disk space, lazy recalculation of model)", new EnumValue <ModelCreation>(value))); Parameters[ModelCreationParameterName].Hidden = true; } else if (!Parameters.ContainsKey(ModelCreationParameterName)) { // very old version contains neither ModelCreationParameter nor CreateSolutionParameter Parameters.Add(new FixedValueParameter <EnumValue <ModelCreation> >(ModelCreationParameterName, "Defines the results produced at the end of the run (Surrogate => Less disk space, lazy recalculation of model)", new EnumValue <ModelCreation>(ModelCreation.Model))); Parameters[ModelCreationParameterName].Hidden = true; } #endregion #endregion }
public void AddPointToTypicalSubScope() { TECBid bid = ModelCreation.TestBid(rand); TECTypical typical = null; TECSubScope typSS = null; foreach (TECTypical typ in bid.Systems) { if (typ.Instances.Count > 0) { foreach (TECEquipment equip in typ.Equipment) { if (equip.SubScope.Count > 0) { typical = typ; typSS = equip.SubScope[0]; } } } } Assert.IsNotNull(typical); Assert.IsNotNull(typSS); TECPoint newPoint = ModelCreation.TestPoint(rand, IOType.AI); newPoint.Label = "New Point"; typSS.Points.Add(newPoint); List <TECSubScope> instanceSubScope = typical.GetInstancesFromTypical(typSS); List <TECPoint> instancePoints = typical.GetInstancesFromTypical(newPoint); foreach (TECSubScope instanceSS in instanceSubScope) { TECPoint newInstancePoint = null; foreach (TECPoint point in instanceSS.Points) { if (point.Label == newPoint.Label) { newInstancePoint = point; } } Assert.IsNotNull(newInstancePoint); Assert.IsTrue(instancePoints.Contains(newInstancePoint)); } }
public void RemoveInstanceWithGlobalConnectionToSubScope() { TECBid bid = new TECBid(); bid.Catalogs = ModelCreation.TestCatalogs(rand); TECController controller = ModelCreation.TestProvidedController(bid.Catalogs, rand); bid.AddController(controller); TECTypical typical = new TECTypical(); TECEquipment equipment = new TECEquipment(); TECSubScope subScope = new TECSubScope(); TECDevice device = null; foreach (TECDevice item in bid.Catalogs.Devices) { foreach (TECProtocol prot in item.PossibleProtocols) { if (controller.AvailableProtocols.Contains(prot)) { device = item; break; } } if (device != null) { break; } } if (device == null) { throw new NullReferenceException("Device is Null"); } subScope.Devices.Add(device); equipment.SubScope.Add(subScope); typical.Equipment.Add(equipment); bid.Systems.Add(typical); TECSystem system = typical.AddInstance(); TECSubScope instanceSubScope = typical.GetInstancesFromTypical(subScope).First(x => x.AvailableProtocols.Any(y => y is TECProtocol && controller.AvailableProtocols.Contains(y))); IControllerConnection connection = controller.Connect(instanceSubScope, instanceSubScope.AvailableProtocols.First(y => controller.AvailableProtocols.Contains(y))); Assert.IsTrue(connection is TECNetworkConnection); typical.Instances.Remove(system); Assert.IsTrue((connection as TECNetworkConnection).Children.Count == 0); }
public void AddPanel() { //Arrange TECPanel panel = ModelCreation.TestPanel(bid.Catalogs, rand); panel.AssignRandomScopeProperties(bid.Catalogs, rand); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act bid.Panels.Add(panel); //Assert AssertMaterialVMMatchesCostBatch(matVM, panel.CostBatch); }
public void AddController() { //Arrange TECController controller = ModelCreation.TestProvidedController(bid.Catalogs, rand); controller.AssignRandomScopeProperties(bid.Catalogs, rand); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act bid.AddController(controller); //Assert AssertMaterialVMMatchesCostBatch(matVM, controller.CostBatch); }
public void CopyControllerTest() { Random rand = new Random(0); TECBid bid = ModelCreation.TestBid(rand); TECProvidedController controller = ModelCreation.TestProvidedController(bid.Catalogs, rand); bid.AddController(controller); TECProvidedController copy = controller.CopyController(new Dictionary <Guid, Guid>()) as TECProvidedController; Assert.AreEqual(controller.Type, copy.Type); Assert.IsTrue(controller.IOModules.SequenceEqual(copy.IOModules)); Assert.AreEqual(controller.ChildrenConnections.Count, copy.ChildrenConnections.Count); }
public void GetObjectPathTest() { //Arrange TECBid bid = ModelCreation.TestBid(rand); TECSystem sys = bid.Systems[0]; TECEquipment equip = sys.Equipment[0]; TECSubScope ss = equip.SubScope[0]; TECPoint point = ss.Points[0]; TECController bidController = bid.Controllers[0]; TECController sysController = sys.Controllers[0]; //Act List <ITECObject> bidToPointPath = bid.GetObjectPath(point); List <ITECObject> bidToBidControllerPath = bid.GetObjectPath(bidController); List <ITECObject> bidToSysControllerPath = bid.GetObjectPath(sysController); List <ITECObject> sysToControllerPath = sys.GetObjectPath(sysController); List <ITECObject> noPath = sys.GetObjectPath(bidController); //Assert //Bid to Point Path Assert.AreEqual(bid, bidToPointPath[0]); Assert.AreEqual(sys, bidToPointPath[1]); Assert.AreEqual(equip, bidToPointPath[2]); Assert.AreEqual(ss, bidToPointPath[3]); Assert.AreEqual(point, bidToPointPath[4]); Assert.AreEqual(5, bidToPointPath.Count); //Bid to Bid Controller Path Assert.AreEqual(bid, bidToBidControllerPath[0]); Assert.AreEqual(bidController, bidToBidControllerPath[1]); Assert.AreEqual(2, bidToBidControllerPath.Count); //Bid to System Controller Path Assert.AreEqual(bid, bidToSysControllerPath[0]); Assert.AreEqual(sys, bidToSysControllerPath[1]); Assert.AreEqual(sysController, bidToSysControllerPath[2]); Assert.AreEqual(3, bidToSysControllerPath.Count); //System to Controller Path Assert.AreEqual(sys, sysToControllerPath[0]); Assert.AreEqual(sysController, sysToControllerPath[1]); Assert.AreEqual(2, sysToControllerPath.Count); }
public void AddInstanceTest() { Random rand = new Random(0); TECCatalogs catalogs = ModelCreation.TestCatalogs(rand); TECTypical typical = ModelCreation.TestTypical(catalogs, rand); TECSystem system = typical.AddInstance(); Assert.AreEqual(typical.Equipment.Count, system.Equipment.Count); Assert.AreEqual(typical.ScopeBranches.Count, system.ScopeBranches.Count); Assert.AreEqual(typical.ProposalItems.Count, system.ProposalItems.Count); Assert.AreEqual(typical.Controllers.Count, system.Controllers.Count); Assert.AreEqual(typical.Panels.Count, system.Panels.Count); Assert.AreEqual(typical.MiscCosts.Count, system.MiscCosts.Count); Assert.AreEqual(typical.Controllers.Aggregate(0, (total, next) => total += next.GetAll <TECConnection>().Count), system.GetAll <TECConnection>().Count); }
public void TECSystemTest() { Random rand = new Random(0); TECBid bid = ModelCreation.TestBid(rand); TECSystem originalSystem = ModelCreation.TestSystem(bid.Catalogs, rand); var copy = new TECSystem(originalSystem); //Not fully covered Assert.AreEqual(originalSystem.Name, copy.Name); Assert.AreEqual(originalSystem.CostBatch.GetCost(CostType.TEC), copy.CostBatch.GetCost(CostType.TEC), 0.000001); Assert.AreEqual(originalSystem.CostBatch.GetCost(CostType.Electrical), copy.CostBatch.GetCost(CostType.Electrical), 0.000001); Assert.AreEqual(originalSystem.CostBatch.GetLabor(CostType.TEC), copy.CostBatch.GetLabor(CostType.TEC), 0.000001); Assert.AreEqual(originalSystem.CostBatch.GetLabor(CostType.Electrical), copy.CostBatch.GetLabor(CostType.Electrical), 0.000001); }
public void AddInstanceSystem() { //Arrange TECTypical typical = ModelCreation.TestTypical(bid.Catalogs, rand); typical.AssignRandomScopeProperties(bid.Catalogs, rand); bid.Systems.Add(typical); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act TECSystem instance = typical.AddInstance(); //Assert AssertMaterialVMMatchesCostBatch(matVM, instance.CostBatch); }
public void TotalMatches() { var bid = new TECBid(); var parameters = ModelCreation.TestParameters(rand, bid); var catalogs = ModelCreation.TestCatalogs(rand); bid.Parameters = parameters; bid.Catalogs = catalogs; ChangeWatcher watcher = new ChangeWatcher(bid); SystemSummaryVM summaryVM = new SystemSummaryVM(bid, watcher); List <Tuple <TECEstimator, TECTypical> > estimates = new List <Tuple <TECEstimator, TECTypical> >(); int x = 6; for (int i = 0; i < x; i++) { TECTypical typical1 = createTypical(bid); TECEstimator estimate1 = new TECEstimator(typical1, bid.Parameters, new TECExtraLabor(Guid.NewGuid()), bid.Duration, new ChangeWatcher(typical1)); estimates.Add(new Tuple <TECEstimator, TECTypical>(estimate1, typical1)); } double previous = estimates[0].Item1.TotalPrice; foreach (var thing in estimates) { Assert.AreEqual(thing.Item1.TotalPrice, previous); previous = thing.Item1.TotalPrice; } int y = 0; foreach (var item in estimates) { foreach (SystemSummaryItem system in summaryVM.Systems) { Assert.AreEqual(item.Item1.TotalPrice, system.Estimate.TotalPrice); if (system.Typical == item.Item2) { Assert.AreEqual(system.Estimate.TotalPrice, item.Item1.TotalPrice); y++; break; } } } }
public void RemoveElectricalMisc() { //Arrange TECMisc misc = ModelCreation.TestMisc(bid.Catalogs, rand, CostType.Electrical); bid.MiscCosts.Add(misc); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); CostBatch initial = MatVMToCostBatch(matVM); //Act bid.MiscCosts.Remove(misc); //Assert AssertMaterialVMMatchesCostBatch(matVM, initial - misc.CostBatch); }
public void Redo_Template_Point_Type() { //Arrange var Template = ModelCreation.TestTemplates(rand); IOType edit = IOType.AO; //Act ChangeWatcher watcher = new ChangeWatcher(Template); DoStacker testStack = new DoStacker(watcher); Template.Templates.SystemTemplates[0].Equipment[0].SubScope[0].Points[0].Type = edit; testStack.Undo(); testStack.Redo(); //assert IOType actual = Template.Templates.SystemTemplates[0].Equipment[0].SubScope[0].Points[0].Type; Assert.AreEqual(edit, actual, "Not Redone"); }
public void DragDropCopyTest() { Random rand = new Random(0); var catalogs = ModelCreation.TestCatalogs(rand); var system = ModelCreation.TestSystem(catalogs, rand); var copy = system.DropData() as TECSystem; Assert.AreEqual(system.Controllers.Count, copy.Controllers.Count); Assert.AreEqual(system.Panels.Count, copy.Panels.Count); Assert.AreEqual(system.Equipment.Count, copy.Equipment.Count); Assert.AreEqual(system.MiscCosts.Count, copy.MiscCosts.Count); Assert.AreEqual(system.CostBatch.GetCost(CostType.TEC), copy.CostBatch.GetCost(CostType.TEC), 0.000001); Assert.AreEqual(system.CostBatch.GetCost(CostType.Electrical), copy.CostBatch.GetCost(CostType.Electrical), 0.000001); Assert.AreEqual(system.CostBatch.GetLabor(CostType.TEC), copy.CostBatch.GetLabor(CostType.TEC), 0.000001); Assert.AreEqual(system.CostBatch.GetLabor(CostType.Electrical), copy.CostBatch.GetLabor(CostType.Electrical), 0.000001); }
public void AddElectricalMiscToSystem() { //Arrange TECMisc misc = ModelCreation.TestMisc(bid.Catalogs, rand, CostType.Electrical); TECTypical typical = new TECTypical(); bid.Systems.Add(typical); typical.AddInstance(); MaterialSummaryVM matVM = new MaterialSummaryVM(bid, cw); //Act typical.MiscCosts.Add(misc); //Assert AssertMaterialVMMatchesCostBatch(matVM, misc.CostBatch); }
public void Redo_Template_Device_Cost() { //Arrange var Template = ModelCreation.TestTemplates(rand); double edit = 123; //Act ChangeWatcher watcher = new ChangeWatcher(Template); DoStacker testStack = new DoStacker(watcher); ((Template.Templates.SystemTemplates[0].Equipment[0].SubScope[0].Devices[0] as TECDevice) as TECDevice).Price = edit; testStack.Undo(); testStack.Redo(); //assert double actual = ((Template.Templates.SystemTemplates[0].Equipment[0].SubScope[0].Devices[0] as TECDevice) as TECDevice).Price; Assert.AreEqual(edit, actual, "Not Redone"); }
public void Redo_Template_Device_Manufacturer() { //Arrange var Template = ModelCreation.TestTemplates(rand); TECManufacturer edit = new TECManufacturer(); //Act ChangeWatcher watcher = new ChangeWatcher(Template); DoStacker testStack = new DoStacker(watcher); (Template.Templates.SystemTemplates[0].Equipment[0].SubScope[0].Devices[0] as TECDevice).Manufacturer = edit; testStack.Undo(); testStack.Redo(); //assert TECManufacturer actual = (Template.Templates.SystemTemplates[0].Equipment[0].SubScope[0].Devices[0] as TECDevice).Manufacturer; Assert.AreEqual(edit, actual, "Not Redone"); }
public void Redo_Template_Device_Description() { //Arrange var Template = ModelCreation.TestTemplates(rand); string edit = "Edit"; //Act ChangeWatcher watcher = new ChangeWatcher(Template); DoStacker testStack = new DoStacker(watcher); (Template.Templates.SystemTemplates[0].Equipment[0].SubScope[0].Devices[0] as TECDevice).Description = edit; testStack.Undo(); testStack.Redo(); //assert string actual = (Template.Templates.SystemTemplates[0].Equipment[0].SubScope[0].Devices[0] as TECDevice).Description; Assert.AreEqual(edit, actual, "Not Redone"); }
public void Redo_Template_Equipment_Name() { //Arrange var Template = ModelCreation.TestTemplates(rand); string edit = "Edit"; //Act ChangeWatcher watcher = new ChangeWatcher(Template); DoStacker testStack = new DoStacker(watcher); Template.Templates.SystemTemplates[0].Equipment[0].Name = edit; testStack.Undo(); testStack.Redo(); //assert string actual = Template.Templates.SystemTemplates[0].Equipment[0].Name; Assert.AreEqual(edit, actual, "Not Redone"); }
public async Task <bool> ResetPcCredentialPassword(Credential credential) { await DatabaseFunctions.InitializeStaticStorage(_db).ConfigureAwait(false); try { credential.CredentialsUsername = credential.CredentialsUsername.ToLower(); var credentialFromDb = await _db.Credentials .Where(c => c.CredentialsUsername.Equals(credential.CredentialsUsername)).FirstOrDefaultAsync() .ConfigureAwait(false); if (credentialFromDb == null) { return(false); } var passwordSalt = await DatabaseFunctions.GetPasswordSalt(_db, credential).ConfigureAwait(false); var passwordInDatabase = await DatabaseFunctions.GetPasswordFromDb(_db, credential).ConfigureAwait(false); var decryptPassword = HashServices.Decrypt(passwordSalt, credential.CredentialsPassword); if (!decryptPassword.Equals(passwordInDatabase)) { return(false); } credentialFromDb.PcCredentialPassword = ModelCreation.GenerateRandomString(); StaticStorageServices.AdminMapper[credential.CredentialsUsername] = credentialFromDb.PcCredentialPassword; await EmailServices.SendEmail(credential.CredentialsUsername, $"New Pc Credential Password: {credentialFromDb.PcCredentialPassword}"); await _db.SaveChangesAsync(); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); } }