/// <summary> /// Create CustomerDOTNumber /// </summary> /// <param name="model"></param> /// <returns></returns> public CustomerDOTNumberDTO CreateCustomerDOTNumber(CustomerDOTNumber model) { if (IsActiveProfile) { var CDOTNumber = context.CustomerDOTNumbers.Where(o => o.DOTNumber == model.DOTNumber && o.CustomerID == model.CustomerID) .Select(x => new CustomerDOTNumberDTO { ItemID = x.ItemID, DOTNumber = x.DOTNumber, DOTTag = x.DOTTag, CustomerID = x.CustomerID, CreatedOn = x.CreatedOn, ModifiedOn = x.ModifiedOn, IsActive = x.IsActive, CreatedBy = x.CreatedBy, ModifiedBy = x.ModifiedBy }).FirstOrDefault(); if (CDOTNumber == null) { var customerDOT = new CustomerDOTNumber { CustomerID = model.CustomerID, DOTNumber = CommonFunctions.Trimstring(model.DOTNumber), DOTTag = CommonFunctions.Trimstring(model.DOTTag), IsActive = true, CreatedOn = DateTime.Now, CreatedBy = model.CreatedBy, ModifiedBy = model.CreatedBy, ModifiedOn = DateTime.Now, IsDelete = false }; context.CustomerDOTNumbers.Add(customerDOT); context.SaveChanges(); var CustomerDOT = new CustomerDOTNumberDTO { ItemID = customerDOT.ItemID, DOTNumber = customerDOT.DOTNumber, DOTTag = customerDOT.DOTTag, CustomerID = customerDOT.CustomerID, CreatedOn = customerDOT.CreatedOn, ModifiedOn = customerDOT.ModifiedOn, IsActive = customerDOT.IsActive, CreatedBy = customerDOT.CreatedBy, ModifiedBy = customerDOT.ModifiedBy }; return(CustomerDOT); } else { return(CDOTNumber); } } return(null); }
/// <summary> /// Delete Customer Profile /// </summary> /// <param name="CompanyID"></param> /// <param name="UserID"></param> /// <returns></returns> public bool DeleteCustomer(int CompanyID, string UserID) { TFPMEntities context = new TFPMEntities(); var CProfile = context.CustomerProfiles.FirstOrDefault(o => o.CompanyID.Equals(CompanyID)); if (CProfile != null) { CProfile.isActive = false; CProfile.IsDelete = true; CProfile.ModifiedBy = UserID; CProfile.ModifiedOn = DateTime.Now; context.SaveChanges(); return(true); } return(false); }
/// <summary> /// Assign Userto Account No /// </summary> /// <param name="AccountNo"></param> /// <param name="UserID"></param> /// <param name="ModifiedBy"></param> /// <returns></returns> public AspNetUser AssingUserToAccount(string AccountNo, string UserID, string ModifiedBy) { var Userinfo = context.AspNetUsers.Where(x => x.Id.Equals(UserID) && x.IsDelete.Equals(false) && string.IsNullOrEmpty(x.AccountNumber)).FirstOrDefault(); if (Userinfo != null) { Userinfo.AccountNumber = AccountNo; Userinfo.ModifiedOn = DateTime.Now; Userinfo.ModifiedBy = ModifiedBy; context.SaveChanges(); return(Userinfo); } else { return(null); } }
/// <summary> /// Create Location /// </summary> /// <param name="CompanyID"></param> public void CreateLocationChild(int CompanyID, string CreatedBy) { if (IsActiveProfile) { var location = new Location_Configuration { CompanyID = CompanyID, Key = "Location", Value = "Location", CreatedOn = DateTime.Now, Relation = 0, CreatedBy = CreatedBy }; context.Location_Configuration.Add(location); context.SaveChanges(); } }
public ManualRSI InsertInspectionEntry(ManualRSI Rsi) { if (IsActiveProfile && CheckDotExists(Rsi.DOTNumber, Rsi.CompanyID)) { var manualRsi = context.ManualRSIs.FirstOrDefault(x => x.CompanyID == Rsi.CompanyID && x.DOTNumber == Rsi.DOTNumber && x.InspectionDate == Rsi.InspectionDate && x.InspectionID == Rsi.InspectionID && x.DriverLicenseNumber == Rsi.DriverLicenseNumber); if (manualRsi == null) { var MRsi = new ManualRSI { CompanyID = Rsi.CompanyID, Comments = Rsi.Comments, CompanyVehicleNumber = Rsi.CompanyVehicleNumber, CreatedBy = Rsi.CreatedBy, CreatedOn = Rsi.CreatedOn, DisciplineActionIssued = Rsi.DisciplineActionIssued, DOTNumber = Rsi.DOTNumber, DriverFirstName = Rsi.DriverFirstName, DriverLastName = Rsi.DriverLastName, DriverLicenseNumber = Rsi.DriverLicenseNumber, DriverLicenseState = Rsi.DriverLicenseState, DriverLog = Rsi.DriverLog, InspectionDate = Rsi.InspectionDate, InspectionID = Rsi.InspectionID, InspectionReceived = Rsi.InspectionReceived, InspectionState = Rsi.InspectionState, ModifiedBy = Rsi.ModifiedBy, ModifiedOn = Rsi.ModifiedOn, NoticeNumber = Rsi.NoticeNumber, OOS = Rsi.OOS, OtherViolation = Rsi.OtherViolation, RepairWorkOrder = Rsi.RepairWorkOrder, ReportNumber = Rsi.ReportNumber, VehicleLicenseNumber = Rsi.VehicleLicenseNumber, Violations = Rsi.Violations, LocationCode = Rsi.LocationCode, DriverDOB = Rsi.DriverDOB, AdminNotes = Rsi.AdminNotes, INSP_ID = Rsi.INSP_ID }; context.ManualRSIs.Add(MRsi); context.SaveChanges(); return(MRsi); } else { manualRsi.Comments = Rsi.Comments; manualRsi.CompanyVehicleNumber = Rsi.CompanyVehicleNumber; manualRsi.DisciplineActionIssued = Rsi.DisciplineActionIssued; manualRsi.DriverFirstName = Rsi.DriverFirstName; manualRsi.DriverLastName = Rsi.DriverLastName; manualRsi.DriverLog = Rsi.DriverLog; manualRsi.InspectionReceived = Rsi.InspectionReceived; manualRsi.Violations = Rsi.Violations; manualRsi.RepairWorkOrder = Rsi.RepairWorkOrder; manualRsi.OtherViolation = Rsi.OtherViolation; manualRsi.InspectionState = Rsi.InspectionState; manualRsi.InspectionReceived = Rsi.InspectionReceived; manualRsi.LocationCode = Rsi.LocationCode; manualRsi.DriverDOB = Rsi.DriverDOB; manualRsi.AdminNotes = Rsi.AdminNotes; manualRsi.ModifiedBy = Rsi.ModifiedBy; manualRsi.ModifiedOn = Rsi.ModifiedOn; context.SaveChanges(); } return(manualRsi); } return(null); }
/// <summary> /// Create Customer/Company Profiler when Initial Time /// </summary> /// <param name="model"></param> /// <returns></returns> public CustomerProfileDTO CreateCustomerProfile(CustomerProfile model, string UserID) { TFPMEntities context = new TFPMEntities(); var CProfile = context.CustomerProfiles.Where(o => o.CustomerName.Equals(model.CustomerName)) .Select(x => new CustomerProfileDTO { CompanyID = x.CompanyID, CustomerName = x.CustomerName, City = x.City, State = x.State, AccountNumber = x.AccountNumber, AccountOwnerEmail = x.AccountOwnerEmail, AccountOwnerName = x.AccountOwnerName, AddressLine1 = x.AddressLine1, AddressLine2 = x.AddressLine2, ZipCode = x.ZipCode, CompanyLogo = x.CompanyLogo, CreatedOn = x.CreatedOn, DotCount = x.CustomerDOTNumbers.Count(a => a.IsDelete == false), UserCount = x.AspNetUsers.Count(a => a.IsActive == true), ModifiedOn = x.ModifiedOn, isActive = x.isActive, CreatedBy = x.CreatedBy, ModifiedBy = x.ModifiedBy }).FirstOrDefault();; if (CProfile == null) { var customer = new CustomerProfile { CustomerName = model.CustomerName.Trim(), CompanyLogo = CommonFunctions.Trimstring(model.CompanyLogo), AccountOwnerEmail = CommonFunctions.Trimstring(model.AccountOwnerEmail), AccountOwnerName = CommonFunctions.Trimstring(model.AccountOwnerName), AddressLine1 = CommonFunctions.Trimstring(model.AddressLine1), AddressLine2 = CommonFunctions.Trimstring(model.AddressLine2), City = CommonFunctions.Trimstring(model.City), State = CommonFunctions.Trimstring(model.State), ZipCode = CommonFunctions.Trimstring(model.ZipCode), CreatedBy = UserID, CreatedOn = DateTime.Now, isActive = true, IsDelete = false }; context.CustomerProfiles.Add(customer); context.SaveChanges(); customer.AccountNumber = model.CustomerName.Trim()[0].ToString().ToLower() + customer.CompanyID.ToString();//Account NUmber Generate logic context.SaveChanges(); LocationConfig loc = new TF_BusinessLayer.LocationConfig(); loc.CreateLocationChild(customer.CompanyID, UserID); var CustomerDTO = new CustomerProfileDTO { CompanyID = customer.CompanyID, CustomerName = customer.CustomerName, City = customer.City, State = customer.State, AccountNumber = customer.AccountNumber, AccountOwnerEmail = customer.AccountOwnerEmail, AccountOwnerName = customer.AccountOwnerName, AddressLine1 = customer.AddressLine1, AddressLine2 = customer.AddressLine2, ZipCode = customer.ZipCode, CompanyLogo = customer.CompanyLogo, CreatedOn = customer.CreatedOn, DotCount = customer.CustomerDOTNumbers.Count(a => a.IsDelete == false), UserCount = customer.AspNetUsers.Count(a => a.IsActive == true), ModifiedOn = customer.ModifiedOn, isActive = customer.isActive, CreatedBy = customer.CreatedBy, ModifiedBy = customer.ModifiedBy }; return(CustomerDTO); } else { return(CProfile); } }
/// <summary> /// Update Customer Profile /// </summary> /// <param name="model"></param> /// <param name="RoleNames"></param> /// <param name="UserID"></param> /// <returns></returns> public CustomerProfileDTO UpdateCustomerProfile(CustomerProfile model, string RoleNames, string UserID) { TFPMEntities context = new TFPMEntities(); var CProfile = context.CustomerProfiles.Where(o => o.CompanyID.Equals(model.CompanyID)).FirstOrDefault(); if (CProfile != null) { if (RoleNames.Contains(Roles.PortalAdmin) || RoleNames.Contains(Roles.SuperAdmin)) { //Same Company Data Update if (CProfile.CustomerName == model.CustomerName) { CProfile.CompanyLogo = CommonFunctions.Trimstring(model.CompanyLogo); CProfile.AccountOwnerEmail = CommonFunctions.Trimstring(model.AccountOwnerEmail); CProfile.AccountOwnerName = CommonFunctions.Trimstring(model.AccountOwnerName); CProfile.AddressLine1 = CommonFunctions.Trimstring(model.AddressLine1); CProfile.AddressLine2 = CommonFunctions.Trimstring(model.AddressLine2); CProfile.City = CommonFunctions.Trimstring(model.City); CProfile.State = CommonFunctions.Trimstring(model.State); CProfile.ZipCode = CommonFunctions.Trimstring(model.ZipCode); CProfile.ModifiedOn = DateTime.Now; CProfile.ModifiedBy = UserID; CProfile.isActive = model.isActive; } else { //New company data Update if (!context.CustomerProfiles.Where(o => o.CustomerName == model.CustomerName).Any()) { CProfile.CustomerName = CommonFunctions.Trimstring(model.CustomerName); CProfile.CompanyLogo = CommonFunctions.Trimstring(model.CompanyLogo); CProfile.AccountOwnerEmail = CommonFunctions.Trimstring(model.AccountOwnerEmail); CProfile.AccountOwnerName = CommonFunctions.Trimstring(model.AccountOwnerName); CProfile.AddressLine1 = CommonFunctions.Trimstring(model.AddressLine1); CProfile.AddressLine2 = CommonFunctions.Trimstring(model.AddressLine2); CProfile.City = CommonFunctions.Trimstring(model.City); CProfile.State = CommonFunctions.Trimstring(model.State); CProfile.ZipCode = CommonFunctions.Trimstring(model.ZipCode); CProfile.ModifiedOn = DateTime.Now; CProfile.ModifiedBy = UserID; CProfile.isActive = model.isActive; } else { return(null); } } } else { CProfile.AddressLine1 = CommonFunctions.Trimstring(model.AddressLine1); CProfile.AddressLine2 = CommonFunctions.Trimstring(model.AddressLine2); CProfile.City = CommonFunctions.Trimstring(model.City); CProfile.State = CommonFunctions.Trimstring(model.State); CProfile.ZipCode = CommonFunctions.Trimstring(model.ZipCode); CProfile.ModifiedOn = DateTime.Now; CProfile.ModifiedBy = UserID; } context.SaveChanges(); var CustomerDTO = new CustomerProfileDTO { CompanyID = CProfile.CompanyID, CustomerName = CProfile.CustomerName, City = CProfile.City, State = CProfile.State, AccountNumber = CProfile.AccountNumber, AccountOwnerEmail = CProfile.AccountOwnerEmail, AccountOwnerName = CProfile.AccountOwnerName, AddressLine1 = CProfile.AddressLine1, AddressLine2 = CProfile.AddressLine2, ZipCode = CProfile.ZipCode, CompanyLogo = CProfile.CompanyLogo, CreatedOn = CProfile.CreatedOn, DotCount = CProfile.CustomerDOTNumbers.Count(a => a.IsDelete == false), UserCount = CProfile.AspNetUsers.Count(a => a.IsActive == true), ModifiedOn = CProfile.ModifiedOn, isActive = CProfile.isActive, CreatedBy = CProfile.CreatedBy, ModifiedBy = CProfile.ModifiedBy }; return(CustomerDTO); } else { return(null); } }