public void Delete(Guid documentStorageId) { _documentStorage.DeleteDocument(documentStorageId); using (DVSContext dc = new DVSContext()) { var tDocument = dc.DocumentInfos.SingleOrDefault(d => d.DocumentStorageId == documentStorageId); if (tDocument != null) { dc.DocumentInfos.Remove(tDocument); dc.SaveChanges(); } } }
private void CreateTestDataForAscGovLicense() { using (DVSContext context = new DVSContext()) { var licenses = new AscGovLicense[] { new AscGovLicense(){ LicenseNumber = "1", AppraiserStateId = "NY", LicenseStateId="NY", ExpirationDate = DateTime.Now, IsStatusInactive = true, City="22"}, new AscGovLicense(){ LicenseNumber = "1", LicenseStateId="FL", ExpirationDate = DateTime.Now.AddYears(1), IsStatusInactive = false }, new AscGovLicense(){ LicenseNumber ="2", LicenseStateId="NY", ExpirationDate = expiredDate, IsStatusInactive = false}, new AscGovLicense(){ LicenseNumber="3", LicenseStateId="NY", ExpirationDate= DateTime.Now.AddYears(1), IsStatusInactive = false }}; foreach (var license in licenses) context.AscGovLicenses.Add(license); context.SaveChanges(); } }
public Guid StoreDocument(DocumentInfo documentInfo, byte[] document) { using (DVSContext dc = new DVSContext()) { documentInfo.DocumentStorageId = documentInfo.DocumentStorageId == Guid.Empty ? Guid.NewGuid() : documentInfo.DocumentStorageId; documentInfo.Name = documentInfo.Name ?? String.Empty; documentInfo.AddedByUserId = documentInfo.AddedByUserId; documentInfo.DateAdded = documentInfo.DateAdded == default(DateTime) ? DateTime.Now : documentInfo.DateAdded; dc.DocumentInfos.Add(documentInfo); dc.SaveChanges(); } _documentStorage.StoreDocument(document, documentInfo.DocumentStorageId); return documentInfo.DocumentStorageId; }
public void TaskSchedulerManager_Task_AssignmentAppraisersForOrder_Duplicates() { var testOrder = OrderServiceTest.CreateTestOrder(); var duplicateOrder = OrderServiceTest.CreateTestOrder(); using (var db = new DVSContext()) { db.Orders.Attach(testOrder); db.Orders.Attach(duplicateOrder); testOrder.AppraisalInfo.DuplicateOrderId = duplicateOrder.Id; duplicateOrder.AcceptedAppraiserUserId = TestConstants.TestAppraiserUser; var appraiserUser = db.AppraiserUsers.Find(TestConstants.TestAppraiserUser); appraiserUser.ServiceArea = new AppraiserServiceArea(); appraiserUser.ServiceArea.Longitude = 1; appraiserUser.ServiceArea.Latitude = 1; appraiserUser.ServiceArea.ServiceAreaRadiusId = 1; db.SaveChanges(); } var taskParams = new List<TaskParam>(); taskParams.Add(new TaskParam(TaskParamsKey.OrderId, testOrder.Id.ToString())); int taskId = TestTaskLifeCycleInternal(TaskTypeEnum.AssignmentAppraisersForOrder, taskParams); using (var dc = new TaskQueueContext()) { var duplicateOrderTask = dc.Tasks.Single(e => e.ParentTaskId == taskId); duplicateOrderTask.Should().NotBeNull(); duplicateOrderTask.MinStartDate.Should().HaveValue(); } }
protected void ClearDVSContext() { using (var dc = new DVSContext()) { //foreach (var item in dc.ClientUsers) dc.ClientUsers.Remove(item); //foreach (var item in dc.Licenses) dc.Licenses.Remove(item); //foreach (var item in dc.AppraiserUsers) dc.AppraiserUsers.Remove(item); //foreach (var item in dc.AppraisalCompanyDetails) dc.AppraisalCompanyDetails.Remove(item); //foreach (var item in dc.AppraisalCompanyContacts) dc.AppraisalCompanyContacts.Remove(item); //foreach (var item in dc.ClientCompanies) dc.ClientCompanies.Remove(item); //foreach (var item in dc.ClientCompanies) dc.ClientCompanies.Remove(item); //foreach (var item in dc.DvsUsers) dc.DvsUsers.Remove(item); //foreach (var item in dc.Users) dc.Users.Remove(item); //foreach (var item in dc.Addresses) dc.Addresses.Remove(item); //foreach (var item in dc.AppraiserFees) dc.AppraiserFees.Remove(item); //foreach (var item in dc.AppraiserOrders) dc.AppraiserOrders.Remove(item); //foreach (var item in dc.DocumentInfos) dc.DocumentInfos.Remove(item); //foreach (var item in dc.HUDAppraiserContactInfos) dc.HUDAppraiserContactInfos.Remove(item); //foreach (var item in dc.HUDAppraiserLicenses) dc.HUDAppraiserLicenses.Remove(item); //foreach (var item in dc.LenderCompanies) dc.LenderCompanies.Remove(item); //foreach (var item in dc.LenderUserDetails) dc.LenderUserDetails.Remove(item); //foreach (var item in dc.Notifications) dc.Notifications.Remove(item); //foreach (var item in dc.Orders) dc.Orders.Remove(item); //foreach (var item in dc.WidgetsConfigs) dc.WidgetsConfigs.Remove(item); dc.Database.ExecuteSqlCommand(@" declare @tblName nvarchar(100), @sql nvarchar(100), @i int,@err int declare tbl cursor for select name, (select COUNT(*) from sys.objects where parent_object_id=ob.object_id and schema_id=1) c from sys.objects ob where [type]='U' and schema_id=1 and name<>'Roles' order by c desc set @err=1 while @err=1 begin set @err=0 OPEN tbl FETCH next FROM tbl INTO @tblName,@i WHILE @@FETCH_STATUS = 0 BEGIN set @sql='delete from '+ @tblName begin try exec (@sql) end try begin catch set @err=1 end catch FETCH NEXT FROM tbl INTO @tblName,@i END CLOSE tbl end DEALLOCATE tbl"); /* dc.Database.ExecuteSqlCommand(@" delete from ClientUsers delete from Licenses delete from AppraiserUsers delete from AppraisalCompanyDetails delete from AppraisalCompanyContacts delete from AppraiserContacts delete from AppraiserServiceAreas delete from ClientCompanyBranches delete from ClientCompanies delete from ClientCompanyProfiles delete from DvsUsers delete from Phones delete from Users delete from Addresses"); */ dc.SaveChanges(); } }
public static Order CreateTestOrder(LoanType loanType = LoanType.Conventional, bool supplementalREOAddendum = false) { using (var db = new DVSContext()) { Order order = new Order() { GeneralInfo = new OrderGeneralInfo() { PropertyAddress = new Address() { ZIP = "12345", State = "NY" }, }, AppraisalInfo = new OrderAppraisalInfo() { PropertyTypeId = 1, //Single Family Residence - Attached OccupancyTypeId = 1, AppraisalTypeId = 1, Rush = true, AppraisalForm = 1, LoanType = loanType, SupplementalREOAddendum = supplementalREOAddendum }, FeeInfo = new OrderFeeInfo() { AppraisalFee = 100 }, DueDate = DateTime.Now.AddDays(1), Latitude = 42.8140, Longitude = -73.94, OrderPublicId = Guid.NewGuid().ToString().Replace("-", String.Empty).Substring(0, 20), CreationDate = DateTime.Now, OrderStatus = OrderStatus.PendingAssignment, CreatedByClientUserId = 1 }; db.Orders.Add(order); db.SaveChanges(); return order; } }
public void OrderServiceTest_AssignmentOrdersDuplicates() { var testOrder = CreateTestOrder(); var duplicateOrder = CreateTestOrder(); using (var db = new DVSContext()) { db.Orders.Attach(testOrder); db.Orders.Attach(duplicateOrder); testOrder.AppraisalInfo.DuplicateOrderId = duplicateOrder.Id; duplicateOrder.AcceptedAppraiserUserId = TestConstants.TestAppraiserUser; db.SaveChanges(); } var nextDateTime = _orderAssignmentService.AssignmentAppraisersForOrder(testOrder.Id, 0, DateTime.Now); nextDateTime.Should().HaveValue(); _appraiserOrderDeliveryService.Received(1).SendOrderInvitations( Arg.Is<Order>(e => e.Id == testOrder.Id), Arg.Is<AppraiserUser[]>(e => e.Length == 1 && e[0].Id == TestConstants.TestAppraiserUser)); }
private void AddAppraiserUser(int currentScore, double feeAmount, bool addFHASurchargeFee = false, bool addSupplementalREOAddendumFee = false) { using (var db = new DVSContext()) { AppraiserUser appraiserUser = new AppraiserUser() { Status = AppraiserUserStatus.Active, ServiceArea = new AppraiserServiceArea() { Latitude = 42.8141F, // Distance ~ 7 mil Longitude = -73.94F, ServiceAreaRadiusId = 3 // 10 mil }, User = new User() { LastName = "LastName", FirstName = "FirtsName", Email = Guid.NewGuid().ToString().Replace("-", String.Empty) + "@mail.com", Salt = "123", Roles = new Role[] { db.Roles.Find(1) // Appraiser } }, Licenses = new License[] { new License() { Status = LicenseStatus.Active, ExpirationDate = DateTime.Now.AddYears(1), State = "NY", LicenseNumber = "1", LicenseTypeId = 2, FHARoster = true } }, QC = new AppraiserQC() { ScoreHistory = new AppraiserScoreHistoryEntry[] { new AppraiserScoreHistoryEntry(){ ScoreValue = 50, ChangeDate = DateTime.Now.AddDays(-10), ChangeReasonId = 1}, new AppraiserScoreHistoryEntry(){ ScoreValue = currentScore, ChangeDate = DateTime.Now.AddDays(-5), ChangeReasonId = 1}, } }, Fees = new Collection<AppraiserFee>() { new AppraiserFee { Amount = feeAmount, ProductId = 1 }, } }; if (addFHASurchargeFee) { appraiserUser.Fees.Add(new AppraiserFee { Amount = 200, ProductId = 36 }); } if (addSupplementalREOAddendumFee) { appraiserUser.Fees.Add(new AppraiserFee { Amount = 200, ProductId = 37 }); } db.AppraiserUsers.Add(appraiserUser); db.SaveChanges(); } }