public ActionResult Delete(int?taxPK) { ITaxesRepository taxesRepository = new TaxesRepository(db); if (taxPK != null) { Tax tax = taxesRepository.GetTaxByPK((int)taxPK); tax.Deleted = true; taxesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("DELETE", tax.TaxPK); } return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
public ActionResult Edit(int?taxPK) { if (taxPK != null) { ITaxesRepository taxesRepository = new TaxesRepository(db); Tax tax = taxesRepository.GetTaxByPK((int)taxPK); TaxView taxView = new TaxView(); taxView.ConvertFrom(tax, taxView); return(View(taxView)); } else { return(RedirectToAction("Index", "Tax")); } }
public ActionResult Index() { ITaxesRepository taxesRepository = new TaxesRepository(db); int page = !String.IsNullOrWhiteSpace(Request.QueryString["page"]) ? Convert.ToInt32(Request.QueryString["page"]) : 1; int pageSize = !String.IsNullOrWhiteSpace(Request.QueryString["pageSize"]) ? Convert.ToInt32(Request.QueryString["pageSize"]) : Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ResultsPerPage"]); string sortOrder = !String.IsNullOrWhiteSpace(Request.QueryString["sortOrder"]) ? Request.QueryString["sortOrder"] : "DESC"; string sortColumn = !String.IsNullOrWhiteSpace(Request.QueryString["sortColumn"]) ? Request.QueryString["sortColumn"] : "TaxPK"; string ordering = sortColumn + " " + sortOrder; ordering = ordering.Trim(); IQueryable <Tax> taxes = taxesRepository.GetValid() .OrderBy(ordering); if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"])) { string searchString = Request.QueryString["searchString"].ToString(); taxes = taxes.Where(c => c.Name.Contains(searchString)); } taxes = taxes.Page(page, pageSize); if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"])) { string searchString = Request.QueryString["searchString"].ToString(); ViewData["numberOfRecords"] = taxesRepository.GetValid().Where(c => c.Name.Contains(searchString)).Count(); } else { ViewData["numberOfRecords"] = taxesRepository.GetValid().Count(); } int numberOfPages = ((int)ViewData["numberOfRecords"] + pageSize - 1) / pageSize; if (page > numberOfPages) { string url = LinkHelper.getQueryStringArray(new string[] { "page" }); return(Redirect("Tax?" + url + "page=" + numberOfPages)); } else { return(View("Index", taxes.ToList())); } }
public ActionResult Edit(TaxView taxModel) { if (ModelState.IsValid) { ITaxesRepository taxesRepository = new TaxesRepository(db); Tax tax = taxesRepository.GetTaxByPK((int)taxModel.TaxPK); taxModel.ConvertTo(taxModel, tax); taxesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", tax.TaxPK); return(RedirectToAction("Index", "Tax")); } else { return(View(taxModel)); } }
public ActionResult Add(TaxView taxView) { if (ModelState.IsValid) { ITaxesRepository taxesRepository = new TaxesRepository(db); Tax tax = new Tax(); taxView.ConvertTo(taxView, tax); taxesRepository.Add(tax); taxesRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("INSERT", tax.TaxPK); return(RedirectToAction("Index", "Tax")); } else { return(View(taxView)); } }
public Orders Calculate(Orders order) { Products selectedProduct = ProductsRepository.LoadProducts() .FirstOrDefault(p => p.ProductType == order.ProductType); Taxes selectedTax = TaxesRepository.LoadTaxes() .FirstOrDefault(t => t.StateAbbreviation == order.State); if (selectedProduct == null) { throw new Exception("Product not found!"); } if (selectedTax == null) { throw new Exception("State not found!"); } order.CostPerSquareFoot = selectedProduct.CostPerSquareFoot; order.LaborCostPerSquareFoot = selectedProduct.LaborCostPerSquareFoot; order.TaxRate = selectedTax.TaxRate; return(order); }
public AddOrderResponse OrderAdd(DateTime date, Order order, int originalOrderNumber) { AddOrderResponse response = new AddOrderResponse(); response.order = new Order(); if (order.OrderDate < DateTime.Now) { response.Success = false; response.Message = "The date you entered was not in the future."; return(response); } if (order.Area < 100.00M) { response.Success = false; response.Message = "The area you entered was not greater than 100 sq feet."; return(response); } TaxesRepository taxRepo = new TaxesRepository(); Taxes tax = null; tax = taxRepo.List().FirstOrDefault(t => t.StateAbbreviation.ToUpper() == order.State); if (tax == null) { response.Success = false; response.Message = "The state abbreviation you entered does not match to any state we do business in"; return(response); } ProductRepository productRepo = new ProductRepository(); Product product = null; product = productRepo.List().FirstOrDefault(p => p.ProductType.ToUpper() == order.ProductType.ToUpper()); if (product == null) { response.Success = false; response.Message = "The product type you entered does not match to any of the prodcuts that we offer."; return(response); } bool result = order.CustomerName.All(c => Char.IsLetterOrDigit(c) || c == '.' || c == ',' || c == ' '); order.CustomerName = order.CustomerName.Trim(); if (order.CustomerName == string.Empty) { response.Success = false; response.Message = "The customer name you entered cannot contain only spaces"; return(response); } if (result == false) { response.Success = false; response.Message = "The customer name you entered contained an invalid value"; return(response); } else { _ordersRepository.Add(order, originalOrderNumber); response.Success = true; return(response); } }
public ActionResult LegalEntities(string Name, string OIB, string MB, string MBS, int?BankPK, int?TaxPK, int?FormPK, int?ActivityPK, int?SubstationPK, int?CommercialCourtPK, int?NumberOfEmployeesFrom, int?NumberOfEmployeesTo, int?FundamentalCapitalFrom, int?FundamentalCapitalTo, string TouristOffice, string MonumentAnnuity) { string sortOrder = !string.IsNullOrWhiteSpace(Request.QueryString["sortOrder"]) ? Request.QueryString["sortOrder"] : "DESC"; string sortColumn = !string.IsNullOrWhiteSpace(Request.QueryString["sortColumn"]) ? Request.QueryString["sortColumn"] : "LegalEntityPK"; string ordering = sortColumn + " " + sortOrder; ordering = ordering.Trim(); IBanksRepository banksRepository = new BanksRepository(db); ITaxesRepository taxesRepository = new TaxesRepository(db); IFormsRepository formsRepository = new FormsRepository(db); IActivitiesRepository activitiesRepository = new ActivitiesRepository(db); ISubstationsRepository substationsRepository = new SubstationsRepository(db); ICommercialCourtsRepository commercialCourtsRepository = new CommercialCourtsRepository(db); // Binding DDL for report search ViewBag.Banks = new SelectList(banksRepository.GetValid().OrderBy("Name ASC").ToList(), "BankPK", "Name", BankPK); ViewBag.Taxes = new SelectList(taxesRepository.GetValid().OrderBy("Name ASC").ToList(), "TaxPK", "Name", TaxPK); ViewBag.Forms = new SelectList(formsRepository.GetValid().OrderBy("Name ASC").ToList(), "FormPK", "Name", FormPK); ViewBag.Activities = new SelectList(activitiesRepository.GetValid().OrderBy("Name ASC").ToList(), "ActivityPK", "Name", ActivityPK); ViewBag.Substations = new SelectList(substationsRepository.GetValid().OrderBy("Name ASC").ToList(), "SubstationPK", "Name", SubstationPK); ViewBag.CommercialCourts = new SelectList(commercialCourtsRepository.GetValid().OrderBy("Name ASC").ToList(), "CommercialCourtPK", "Name", CommercialCourtPK); if (BankPK != null) { ViewBag.Bank = banksRepository.GetBankByPK((int)BankPK).Name; } if (TaxPK != null) { ViewBag.Tax = taxesRepository.GetTaxByPK((int)TaxPK).Name; } if (SubstationPK != null) { ViewBag.Substation = substationsRepository.GetSubstationByPK((int)SubstationPK).Name; } if (CommercialCourtPK != null) { ViewBag.CommercialCourt = commercialCourtsRepository.GetCommercialCourtByPK((int)CommercialCourtPK).Name; } if (FormPK != null) { ViewBag.Form = formsRepository.GetFormByPK((int)FormPK).Name; } if (ActivityPK != null) { ViewBag.Activity = activitiesRepository.GetActivityByPK((int)ActivityPK).Name; } bool?TouristOfficeFlag = null; bool?MonumentAnnuityFlag = null; if (TouristOffice == "on") { TouristOfficeFlag = true; } if (MonumentAnnuity == "on") { MonumentAnnuityFlag = true; } // Applying filters IQueryable <LegalEntityView> legalEntities = LegalEntityView.GetLegalEntitiesReport(db, Name, OIB, MB, MBS, BankPK, TaxPK, FormPK, ActivityPK, SubstationPK, CommercialCourtPK, NumberOfEmployeesFrom, NumberOfEmployeesTo, FundamentalCapitalFrom, FundamentalCapitalTo, TouristOfficeFlag, MonumentAnnuityFlag) .OrderBy(ordering); // Excluding temporary deleted items from view legalEntitiesPKsToExclude = new List <int>(); // Empty session on first request if (Request.QueryString.Count == 0) { Session["legalEntitiesPKsToExclude"] = null; } if (Session["legalEntitiesPKsToExclude"] != null) { legalEntitiesPKsToExclude = (List <int>)Session["legalEntitiesPKsToExclude"]; legalEntities = legalEntities.Where(c => !legalEntitiesPKsToExclude.Contains(c.LegalEntityPK)); } return(View("LegalEntities", legalEntities.ToList())); }
public List <Taxes> GetListTaxes() { List <Taxes> taxes = TaxesRepository.LoadTaxes(); return(taxes); }
public void Execute() { OrderManager manager = OrderManagerFactory.Create(); DateTime date = UserIO.GetDateFromUser("Enter the date the order was placed (example \"MM-DD-YYYY\"):"); DisplayOrderResponse response = manager.OrderLookup(date); Console.Clear(); if (response.Success) { Order order = null; while (order == null) { ConsoleIO.DisplayOrderDetails(response.Order, response.Date); order = UserIO.GetOrderFromUser("Which order would you like to edit? (Use Order ID) :", response.Order); if (order == null) { Console.WriteLine("The input did not match an order ID"); } else { break; } } while (true) { string customerName = UserIO.GetStringFromUserCanBeNull($"Please enter a new name for the customer. The current customer name is {order.CustomerName}. If you do no wish to change this field hit enter without entering any data. :"); if (customerName.Trim() == string.Empty) { break; } bool result = order.CustomerName.All(c => Char.IsLetterOrDigit(c) || c == '.' || c == ',' || c == ' '); if (result == false) { Console.WriteLine("The customer name you entered contained an invalid value"); Console.ReadLine(); } else { order.CustomerName = customerName; break; } } Console.Clear(); TaxesRepository taxRepo = new TaxesRepository(); ConsoleIO.DisplayTaxRepo(taxRepo.List()); Taxes tax = null; while (tax == null) { string state = UserIO.GetStringFromUserCanBeNull($"Please enter the new state Abbreviation for the customer. The current state is {order.State}.If you do no wish to change this field hit enter without entering any data. :").ToUpper(); if (state != string.Empty) { tax = taxRepo.List().FirstOrDefault(t => t.StateAbbreviation.ToUpper() == state); if (tax != null) { order.State = tax.StateAbbreviation; order.TaxRate = tax.TaxRate; break; } else { Console.WriteLine("We do not do business in that state"); Console.WriteLine("Press any key to try again..."); Console.ReadLine(); } } else { break; } } Console.Clear(); ProductRepository productRepo = new ProductRepository(); ConsoleIO.DisplayProductRepo(productRepo.List()); Product product = null; while (product == null) { string productType = UserIO.GetStringFromUserCanBeNull($"Please enter the new product type information for the customer. The current product type is {order.ProductType} (Carpet, Laminate, Tile, Wood). If you do no wish to change this field hit enter without entering any data. :").ToUpper(); if (productType != string.Empty) { product = productRepo.List().FirstOrDefault(p => p.ProductType.ToUpper() == productType); if (product != null) { order.CostPerSquareFoot = product.CostPerSquareFoot; order.LaborCostPerSquareFoot = product.LaborCostPerSquareFoot; order.ProductType = product.ProductType; break; } if (product == null) { Console.WriteLine("We do not offer that flooring type."); Console.WriteLine("Press any key to try again..."); Console.ReadKey(); } } else { break; } } Console.Clear(); while (true) { decimal area = UserIO.GetAreaFromUserCanBe0($"Please enter the new area information for this order. The current area is {order.Area}. If you do no wish to change this field hit enter without entering any data. :"); if (area == 0) { break; } else { order.Area = area; break; } } order.MaterialCost = order.Area * order.CostPerSquareFoot; order.LaborCost = order.Area * order.LaborCostPerSquareFoot; order.Total = order.MaterialCost + order.LaborCost + order.Tax; order.Tax = (order.MaterialCost + order.LaborCost) * (order.TaxRate / 100); order.OrderDate = response.Date; order.MaterialCost.ToString(); order.LaborCost.ToString(); order.Tax.ToString(); order.Total.ToString(); string line = "{0, 5} {1, 10} {2, 12} {3,8} {4, 15} {5, 15} {6, 12} {7, 9} {8, 9}"; Console.WriteLine(line, "Order ID", "Order Date", "Cust Name", "State", "Prod Type", "Material Cost", "Labor Cost", "Tax", "Total"); Console.WriteLine("_______________________________________________________________________________________"); string line2 = "{0, 5} {1, 12} {2, 9} {3, 10} {4, 14} {5, 12} {6, 16} {7, 11} {8, 11}"; Console.WriteLine(line2, order.OrderNumber, order.OrderDate.ToString("MM/dd/yyyy"), order.CustomerName, order.State, order.ProductType, String.Format("{0:0.00}", order.MaterialCost), String.Format("{0:0.00}", order.LaborCost), String.Format("{0:0.00}", order.Tax), String.Format("{0:0.00}", order.Total)); string input = UserIO.GetYesOrNoFromUser($"Do you want to save these changes for {order.CustomerName}?"); if (input == "Y") { EditOrderResponse editResponse = manager.OrderEdit(order); if (editResponse.Success == true) { Console.WriteLine("The order has been added."); Console.WriteLine("Press any key to continue..."); Console.ReadLine(); } else { Console.WriteLine(editResponse.Message); Console.WriteLine("The request has been cancelled. Press any key to return to the main menu"); Console.ReadKey(); } } else { Console.WriteLine("You have chosen not to save the changes to the order. Press any key to return to the main menu."); Console.ReadKey(); } } else { Console.WriteLine("There are no orders from that date."); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } }
public static List <LegalEntityAuditView> GetLegalEntityAuditView(ObjectContext context, int relatedEntityPK) { IAuditingDetailsRepository auditingDetailsRepository = new AuditingDetailsRepository(context); IAuditingMasterRepository auditingMasterRepository = new AuditingMasterRepository(context); List <LegalEntityAuditView> legalEntityAuditViewList = new List <LegalEntityAuditView>(); var sessionTokens = (from am in auditingMasterRepository.GetAll().Where(c => c.TableName == "LegalEntities") where am.RelatedEntityPK == relatedEntityPK select new { auditingMasterPK = am.AuditingMasterPK, sessionToken = am.SessionToken }).ToList(); foreach (var item in sessionTokens) { var record = auditingDetailsRepository.GetAuditingDetailByAuditingMasterPK(item.auditingMasterPK).ToList(); LegalEntityAuditView leav = new LegalEntityAuditView(); leav.Name = record.checkString("Name"); leav.ShortName = record.checkString("ShortName"); leav.OIB = record.checkString("OIB"); leav.MB = record.checkString("MB"); leav.MBS = record.checkString("MBS"); leav.ActivityFK = record.checkInteger("ActivityFK"); leav.ActivityDescription = record.checkString("ActivityDescription"); leav.FormFK = record.checkInteger("FormFK"); leav.FundamentalCapital = record.checkDecimal("FundamentalCapital"); leav.CountryFK = record.checkInteger("CountryFK"); leav.CountyFK = record.checkInteger("CountyFK"); leav.PlaceFK = record.checkInteger("PlaceFK"); leav.PostalOfficeFK = record.checkInteger("PostalOfficeFK"); leav.Place = record.checkString("Place"); leav.CityCommunityFK = record.checkInteger("CityCommunityFK"); leav.StreetName = record.checkString("StreetName"); leav.RegionalOfficeFK = record.checkInteger("RegionalOfficeFK"); leav.SubstationFK = record.checkInteger("SubstationFK"); leav.ReferentFK = record.checkInteger("ReferentFK"); leav.DateOfRegistration = record.checkDate("DateOfRegistration"); leav.CommercialCourtFK = record.checkInteger("CommercialCourtFK"); leav.TaxFK = record.checkInteger("TaxFK"); leav.Phone = record.checkString("Phone"); leav.Fax = record.checkString("Fax"); leav.Mobile = record.checkString("Mobile"); leav.EMail = record.checkString("EMail"); leav.FirstContactDate = record.checkDate("FirstContactDate"); leav.TouristOffice = record.checkBoolean("TouristOffice"); leav.TouristOfficeDescription = record.checkString("TouristOfficeDescription"); leav.MonumentAnnuity = record.checkBoolean("MonumentAnnuity"); leav.MonumentAnnuityDescription = record.checkString("MonumentAnnuityDescription"); leav.NumberOfEmployees = record.checkInteger("NumberOfEmployees"); leav.MIORRegistrationNumber = record.checkString("MIORRegistrationNumber"); leav.HZZOObligationNumber = record.checkString("HZZOObligationNumber"); leav.HZZOBussinesEntityCode = record.checkString("HZZOBussinesEntityCode"); leav.ChangeDate = record.checkDate("ChangeDate"); leav.Owner = record.checkBoolean("Owner"); leav.LegalEntity = record.checkBoolean("LegalEntity"); leav.Active = record.checkBoolean("Active"); legalEntityAuditViewList.Add(leav); } // Connect all foreign keys and return data collection as List<LegalEntityAuditView> IFormsRepository formsRepository = new FormsRepository(context); IQueryable <Form> formsTable = formsRepository.GetValid(); IActivitiesRepository activitiesRepository = new ActivitiesRepository(context); IQueryable <Activity> activitiesTable = activitiesRepository.GetValid(); IRegionalOfficesRepository regionalOfficesRepository = new RegionalOfficesRepository(context); IQueryable <RegionalOffice> regionalOfficesTable = regionalOfficesRepository.GetValid(); ISubstationsRepository substationsRepository = new SubstationsRepository(context); IQueryable <Substation> substationsTable = substationsRepository.GetValid(); ICommercialCourtsRepository commercialCourtsRepository = new CommercialCourtsRepository(context); IQueryable <CommercialCourt> commercialCourtsTable = commercialCourtsRepository.GetValid(); ITaxesRepository taxesRepository = new TaxesRepository(context); IQueryable <Tax> taxesTable = taxesRepository.GetValid(); ICountriesRepository countriesRepository = new CountriesRepository(context); IQueryable <Country> countriesTable = countriesRepository.GetValid(); ICountiesRepository countiesRepository = new CountiesRepository(context); IQueryable <County> countiesTable = countiesRepository.GetValid(); ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(context); IQueryable <CityCommunity> cityCommunityTable = citiesCommunitiesRepository.GetValid(); IPostalOfficesRepository postalOfficesRepository = new PostalOfficesRepository(context); IQueryable <PostalOffice> postalOfficeTable = postalOfficesRepository.GetValid(); IPlacesRepository placesRepository = new PlacesRepository(context); IQueryable <Place> placesTable = placesRepository.GetValid(); IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(context); IQueryable <PhysicalEntity> physicalEntitiesTable = physicalEntitiesRepository.GetValid(); List <LegalEntityAuditView> legalEntityAuditView = (from t in legalEntityAuditViewList from t1 in formsTable.Where(tbl => tbl.FormPK == t.FormFK).DefaultIfEmpty() from t2 in activitiesTable.Where(tbl => tbl.ActivityPK == t.ActivityFK).DefaultIfEmpty() from t3 in regionalOfficesTable.Where(tbl => tbl.RegionalOfficePK == t.RegionalOfficeFK).DefaultIfEmpty() from t4 in substationsTable.Where(tbl => tbl.SubstationPK == t.SubstationFK).DefaultIfEmpty() from t5 in commercialCourtsTable.Where(tbl => tbl.CommercialCourtPK == t.CommercialCourtFK).DefaultIfEmpty() from t6 in taxesTable.Where(tbl => tbl.TaxPK == t.TaxFK).DefaultIfEmpty() from t7 in countriesTable.Where(tbl => tbl.CountryPK == t.CountryFK).DefaultIfEmpty() from t8 in countiesTable.Where(tbl => tbl.CountyPK == t.CountyFK).DefaultIfEmpty() from t9 in cityCommunityTable.Where(tbl => tbl.CityCommunityPK == t.CityCommunityFK).DefaultIfEmpty() from t10 in postalOfficeTable.Where(tbl => tbl.PostalOfficePK == t.PostalOfficeFK).DefaultIfEmpty() from t11 in placesTable.Where(tbl => tbl.PlacePK == t.PlaceFK).DefaultIfEmpty() from t12 in physicalEntitiesTable.Where(tbl => tbl.PhysicalEntityPK == t.ReferentFK).DefaultIfEmpty() select new LegalEntityAuditView { LegalEntityPK = t.LegalEntityPK, Name = t.Name != null ? t.Name : null, ShortName = t.ShortName != null ? t.ShortName : null, OIB = t.OIB != null ? t.OIB : null, MB = t.MB != null ? t.MB : null, MBS = t.MBS != null ? t.MBS : null, ActivityFK = t.ActivityFK != null ? t.ActivityFK : null, ActivityDescription = t.ActivityDescription != null ? t.ActivityDescription : null, FormFK = t.FormFK != null ? t.FormFK : null, FundamentalCapital = t.FundamentalCapital != null ? t.FundamentalCapital : null, CountryFK = t.CountryFK != null ? t.CountryFK : null, CountyFK = t.CountyFK != null ? t.CountyFK : null, CityCommunityFK = t.CityCommunityFK != null ? t.CityCommunityFK : null, PostalOfficeFK = t.PostalOfficeFK != null ? t.PostalOfficeFK : null, PlaceFK = t.PlaceFK != null ? t.PlaceFK : null, Place = t.Place != null ? t.Place : null, StreetName = t.StreetName != null ? t.StreetName : null, RegionalOfficeFK = t.RegionalOfficeFK != null ? t.RegionalOfficeFK : null, SubstationFK = t.SubstationFK != null ? t.SubstationFK : null, ReferentFK = t.ReferentFK != null ? t.ReferentFK : null, DateOfRegistration = t.DateOfRegistration != null ? t.DateOfRegistration : null, CommercialCourtFK = t.CommercialCourtFK != null ? t.CommercialCourtFK : null, TaxFK = t.TaxFK != null ? t.TaxFK : null, Phone = t.Phone != null ? t.Phone : null, Fax = t.Fax != null ? t.Fax : null, Mobile = t.Mobile != null ? t.Mobile : null, EMail = t.EMail != null ? t.EMail : null, FirstContactDate = t.FirstContactDate != null ? t.FirstContactDate : null, TouristOffice = t.TouristOffice != null ? t.TouristOffice : null, TouristOfficeDescription = t.TouristOfficeDescription != null ? t.TouristOfficeDescription : null, MonumentAnnuity = t.MonumentAnnuity != null ? t.MonumentAnnuity : null, MonumentAnnuityDescription = t.MonumentAnnuityDescription != null ? t.MonumentAnnuityDescription : null, NumberOfEmployees = t.NumberOfEmployees != null ? t.NumberOfEmployees : null, MIORRegistrationNumber = t.MIORRegistrationNumber != null ? t.MIORRegistrationNumber : null, HZZOObligationNumber = t.HZZOObligationNumber != null ? t.HZZOObligationNumber : null, HZZOBussinesEntityCode = t.HZZOBussinesEntityCode != null ? t.HZZOBussinesEntityCode : null, ChangeDate = t.ChangeDate != null ? t.ChangeDate : null, Owner = t.Owner != null ? t.Owner : null, LegalEntity = t.LegalEntity != null ? t.LegalEntity : null, Active = t.Active != null ? t.Active : null, Deleted = t.Deleted != null ? t.Deleted : null, FormName = t1 != null && t1.Name != null ? t1.Name : null, ActivityName = t2 != null && t2.Name != null ? t2.Name : null, RegionalOfficeName = t3 != null && t3.Name != null ? t3.Name : null, SubstationName = t4 != null && t4.Name != null ? t4.Name : null, ReferentName = t12 != null && t12.Firstname != null && t12.Lastname != null ? t12.Firstname + " " + t12.Lastname : null, CommercialCourtName = t5 != null && t5.Name != null ? t5.Name : null, TaxName = t6 != null && t6.Name != null ? t6.Name : null, CountryName = t7 != null && t7.Name != null ? t7.Name : null, CountyName = t8 != null && t8.Name != null ? t8.Name : null, CityCommunityName = t9 != null && t9.Name != null ? t9.Name : null, PostalOfficeName = t10 != null && t10.Name != null ? t10.Name : null, PlaceName = t11 != null && t11.Name != null ? t11.Name : null, }).OrderBy(c => c.ChangeDate).ToList(); return(legalEntityAuditView); }
public void Execute() { Console.Clear(); Console.WriteLine(" Add Order"); ConsoleIO.DisplaySeparatorBar(); Order order = new Order(); int originalOrderNumber = 0; order.OrderDate = UserIO.GetFutureDateFromUser("Enter the Order Date. This date must be in the future. :"); TaxesRepository taxRepo = new TaxesRepository(); ConsoleIO.DisplayTaxRepo(taxRepo.List()); Taxes tax = null; while (tax == null) { string state = UserIO.GetStringFromUserCanBeNull($"Please enter the state Abbreviation for the customer. :").ToUpper(); if (state != string.Empty) { tax = taxRepo.List().FirstOrDefault(t => t.StateAbbreviation.ToUpper() == state); if (tax != null) { order.State = tax.StateAbbreviation.ToUpper(); order.TaxRate = tax.TaxRate; break; } else { Console.WriteLine("We do not do business in that state"); Console.WriteLine("Press any key to try again..."); Console.ReadLine(); } } else { Console.WriteLine("This may not be empty. Press any key to try again"); Console.ReadKey(); } } Console.Clear(); ProductRepository productRepo = new ProductRepository(); ConsoleIO.DisplayProductRepo(productRepo.List()); Product product = null; while (product == null) { string productType = UserIO.GetStringFromUserCanBeNull($"Please enter the product type information for the customer. :").ToUpper(); if (productType != string.Empty) { product = productRepo.List().FirstOrDefault(p => p.ProductType.ToUpper() == productType); if (product != null) { order.CostPerSquareFoot = product.CostPerSquareFoot; order.LaborCostPerSquareFoot = product.LaborCostPerSquareFoot; order.ProductType = product.ProductType.ToUpper(); break; } if (product == null) { Console.WriteLine("We do not offer that flooring type."); Console.WriteLine("Press any key to try again..."); Console.ReadKey(); } } else { Console.WriteLine("This may not be empty. Press any key to try again."); Console.ReadKey(); } } Console.Clear(); order.Area = UserIO.GetAreaFromUser("Enter the order area (\"Must be more than 100 square feet\") :"); while (true) { string customerName = UserIO.GetStringFromUserCanBeNull($"Please enter a name for the customer. This can only contain Letters, Digits, periods, commas, or spaces. :"); if (customerName.Trim() == string.Empty) { Console.WriteLine("The name customer name cannot be blank. Press any key to try again."); Console.ReadKey(); Console.Clear(); continue; } bool result = customerName.All(c => Char.IsLetterOrDigit(c) || c == '.' || c == ',' || c == ' '); if (result == false) { Console.WriteLine("The customer name you entered contained an invalid value. Press any key to try again"); Console.ReadKey(); Console.Clear(); } else { order.CustomerName = customerName; break; } } Console.Clear(); order.MaterialCost = order.Area * order.CostPerSquareFoot; order.LaborCost = order.Area * order.LaborCostPerSquareFoot; order.Tax = (order.MaterialCost + order.LaborCost) * (order.TaxRate / 100); order.Total = order.MaterialCost + order.LaborCost + order.Tax; OrderManager manager = OrderManagerFactory.Create(); order.MaterialCost.ToString(); order.LaborCost.ToString(); order.Tax.ToString(); order.Total.ToString(); string line = "{0, 5} {1, 10} {2, 12} {3,8} {4, 15} {5, 15} {6, 12} {7, 9} {8, 9}"; Console.WriteLine(line, "Order ID", "Order Date", "Cust Name", "State", "Prod Type", "Material Cost", "Labor Cost", "Tax", "Total"); Console.WriteLine("_______________________________________________________________________________________"); string line2 = "{0, 5} {1, 12} {2, 9} {3, 10} {4, 14} {5, 12} {6, 16} {7, 11} {8, 11}"; Console.WriteLine(line2, order.OrderNumber, order.OrderDate.ToString("MM/dd/yyyy"), order.CustomerName, order.State, order.ProductType, String.Format("{0:0.00}", order.MaterialCost), String.Format("{0:0.00}", order.LaborCost), String.Format("{0:0.00}", order.Tax), String.Format("{0:0.00}", order.Total)); string input = UserIO.GetYesOrNoFromUser($"Do you want to add this order new order for {order.CustomerName}?"); if (input == "Y") { AddOrderResponse addResponse = manager.OrderAdd(order.OrderDate, order, originalOrderNumber); if (addResponse.Success == true) { Console.WriteLine("The order has been added."); Console.WriteLine("Press any key to continue..."); Console.ReadLine(); } else { Console.WriteLine(addResponse.Message); Console.WriteLine("The request has been cancelled. Press any key to return to the main menu"); Console.ReadKey(); } } else { Console.WriteLine("Add order request has been cancelled. Press any key to return to the main menu."); Console.ReadKey(); } }