internal Response addLabBranch(LabBranchDB labBranch) { Response response = Response.Success; try { LabBranch labBranchDb = new LabBranch(); labBranchDb.email = labBranch.email; labBranchDb.password = labBranch.password; labBranchDb.govern = labBranch.govern; labBranchDb.image = labBranch.image; labBranchDb.phone = labBranch.phone; labBranchDb.isAvailableFromHome = labBranch.isAvailableFromHome; labBranchDb.timeFrom = labBranch.timeFrom; labBranchDb.timeTo = labBranch.timeTo; labBranchDb.holidays = labBranch.holidays; labBranchDb.longitude = labBranch.longitude; labBranchDb.latitude = labBranch.latitude; labBranchDb.FireBaseId = labBranch.FireBaseId; labBranchDb.LabId = labBranch.LabId; labBranchDb.rating = labBranch.rating; labBranchDb.reviewId = labBranch.reviewId; labBranchDb.governId = labBranch.governId; labBranchDb.Address = labBranch.address; checkUpContext.LabBranches.Add(labBranchDb); checkUpContext.SaveChanges(); } catch (Exception ex) { response = Response.Fail; } return(response); }
internal Response AddNewAnalysis(TestModel test) { Response response; try { Test testDb = CopyAToB(test); testDb.isNotifiedLab = true; testDb.isNotified = false; DateTime dateNow = DateTime.UtcNow; dateNow.AddHours(4); testDb.dateRequestFormat = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, dateNow.Hour, dateNow.Minute, dateNow.Second); Laboratory laboratory = checkUpContext.Laboratories.Where(w => w.FireBaseId == testDb.labId).FirstOrDefault(); if (laboratory != null) { testDb.labIdDB = laboratory.Id; } LabBranch labBranch = checkUpContext.LabBranches.Where(w => w.FireBaseId == testDb.branchId).FirstOrDefault(); if (labBranch != null) { testDb.branchIdDB = labBranch.Id; } testDb.TestNames = new List <TestName>(); for (int i = 0; i < test.testName.Count; i++) { testDb.TestNames.Add(new TestName() { Name = test.testName[i] }); } testDb.ResultFilespaths = new List <ResultFilespath>(); for (int i = 0; i < test.resultFilespaths.Count; i++) { testDb.ResultFilespaths.Add(new ResultFilespath() { Name = test.resultFilespaths[i] }); } testDb.RoushettaPaths = new List <RoushettaPath>(); for (int i = 0; i < test.roushettaPaths.Count; i++) { testDb.RoushettaPaths.Add(new RoushettaPath() { Name = test.roushettaPaths[i] }); } if (test.address != null) { Address addressObj = new Address(); addressObj.address1 = test.address.address1; addressObj.apartmentNo = test.address.apartmentNo; addressObj.floorNo = test.address.floorNo; addressObj.buildingNo = test.address.buildingNo; addressObj.longitude = test.address.longitude; addressObj.latitude = test.address.latitude; testDb.Address = addressObj; } checkUpContext.Tests.Add(testDb); checkUpContext.SaveChanges(); response = Response.Success; } catch (Exception ex) { response = Response.Fail; } return(response); }