public async Task <AddEditResponse> Add(CommunityRequest cData) { var response = new AddEditResponse(); try { if (cData.isActive.ToLower() != "true") { cData.isActive = "false"; } if (string.IsNullOrEmpty(cData.communityName)) { response.Status = "false"; response.Message = "Please enter community name"; } else if (cData.casteId <= 0) { response.Status = "false"; response.Message = "Invalid caste id"; } else { var addEditResponse = _communityData.Add(cData); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public async Task <AddEditResponse> Add(ReligionRequest rData) { var response = new AddEditResponse(); try { if (rData.isActive.ToLower() != "true") { rData.isActive = "false"; } if (string.IsNullOrEmpty(rData.religionName)) { response.Status = "false"; response.Message = "Please enter religion name"; } else { var addEditResponse = _religionData.Add(rData); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public void CanAddTest() { TestRepository repo = new TestRepository(); OrderManager manager = OrderManagerFactory.Create(); AddEditResponse response = new AddEditResponse(); Order order = new Order(); order.OrderDate = "06012019"; List <Order> orders = repo.GetOrder(order.OrderDate); order.OrderNumber = 1; order.CustomerName = "Tim"; order.State = "KY"; order.Type = "tile"; order.Area = 150; order.MaterialCost = 100M; order.LaborCost = 150M; order.Tax = 40M; order.Total = 290M; response.product = manager.GetProd(response); response.tax = manager.GetTax(response); bool second = true; response = manager.Add(order, second); orders = repo.GetOrder(order.OrderDate); Assert.AreEqual(2, orders.Count); Assert.IsNotNull(response); Assert.IsTrue(response.Success); }
public void CanEditTest(string orderDate, string custName, string abbr, string product, decimal area, bool expectedSuccess) { TestRepository repo = new TestRepository(); OrderManager manager = OrderManagerFactory.Create(); AddEditResponse response = new AddEditResponse(); Order order = new Order(); order.OrderDate = orderDate; List <Order> orders = repo.GetOrder(order.OrderDate); Order editOrder = orders[0]; editOrder.CustomerName = custName; editOrder.Type = product; editOrder.Area = area; editOrder.State = abbr; bool second = true; response = manager.Edit(editOrder, second); response.product = manager.GetProd(response); response.tax = manager.GetTax(response); orders = repo.GetOrder(order.OrderDate); Assert.AreEqual(1, orders.Count); Assert.AreEqual("Tim", orders[0].CustomerName); Assert.IsNotNull(response); Assert.AreEqual(expectedSuccess, response.Success); }
public async Task <AddEditResponse> AddBlock(BlockRequest bData) { var response = new AddEditResponse(); try { if (string.IsNullOrEmpty(bData.blockGovCode)) { response.Status = "false"; response.Message = "Please enter block gov code"; } else { var addEditResponse = _blockData.AddBlock(bData); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public void CanAddTestRules(string orderDate, int orderNum, string custName, string abbr, string product, decimal area, decimal matCost, decimal laborCost, decimal tax, decimal total) { TestRepository repo = new TestRepository(); OrderManager manager = OrderManagerFactory.Create(); AddEditResponse response = new AddEditResponse(); Order order = new Order(); order.OrderDate = orderDate; List <Order> orders = repo.GetOrder(order.OrderDate); order.OrderNumber = orderNum; order.CustomerName = custName; order.State = abbr; order.Type = product; order.Area = area; order.MaterialCost = matCost; order.LaborCost = laborCost; order.Tax = tax; order.Total = total; response.product = manager.GetProd(response); response.tax = manager.GetTax(response); response.order = order; bool second = true; response = manager.Add(order, true); Assert.AreEqual(1, orders.Count); Assert.IsNotNull(response); Assert.IsFalse(response.Success); }
public async Task <AddEditResponse> Add(PHCRequest pData) { var response = new AddEditResponse(); try { if (pData.isActive.ToLower() != "true") { pData.isActive = "false"; } if (string.IsNullOrEmpty(pData.phcGovCode)) { response.Status = "false"; response.Message = "Please enter phc gov code"; } else if (pData.chcId <= 0) { response.Status = "false"; response.Message = "Invalid CHC id"; } else { var addEditResponse = _phcData.Add(pData); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public async Task <AddEditResponse> UpdateStatedetail(UpdateStateRequest sData) { var response = new AddEditResponse(); try { if (string.IsNullOrEmpty(sData.stateGovCode)) { response.Status = "false"; response.Message = "Please enter state gov code"; } else if (string.IsNullOrEmpty(sData.name)) { response.Status = "false"; response.Message = "Please enter state name"; } else { var addEditResponse = _saData.UpdateStatedetail(sData); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public async Task <AddEditResponse> AddDistrict(DistrictRequest dData) { var response = new AddEditResponse(); try { if (dData.isActive.ToLower() != "true") { dData.isActive = "false"; } if (dData.stateId <= 0) { response.Status = "false"; response.Message = "Invalid state id"; } else { var addEditResponse = _districtData.Add(dData); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public async Task <AddEditResponse> AddRIDetail(AddRISitesRequest data) { var riSiteName = ""; var response = new AddEditResponse(); try { foreach (var riRequestData in data.RISiteData) { var riResponse = _saData.AddRIDetail(riRequestData); if (riResponse.message != "") { riSiteName = riSiteName + riResponse.message + ","; } } riSiteName = riSiteName.Remove(riSiteName.Length - 1); response.Status = "true"; response.Message = $"{riSiteName} - added Successfully "; return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public async Task <AddEditResponse> Add(ClinicalDiagnosisRequest cdData) { var response = new AddEditResponse(); try { if (cdData.isActive.ToLower() != "true") { cdData.isActive = "false"; } if (string.IsNullOrEmpty(cdData.diagnosisName)) { response.Status = "false"; response.Message = "Please enter diagnosis name"; } else { var addEditResponse = _clinicalDiagnosisData.Add(cdData); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public async Task <AddEditResponse> Add(UserTypeRequest utData) { var response = new AddEditResponse(); try { if (utData.isActive.ToLower() != "true") { utData.isActive = "false"; } if (string.IsNullOrEmpty(utData.userTypeName)) { response.Status = "false"; response.Message = "Please enter user type name"; } else { var addEditResponse = _userTypeData.Add(utData); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public void Execute() { OrderManager manager = OrderManagerFactory.Create(); AddEditResponse response = new AddEditResponse(); BlankCheck check = new BlankCheck(); Order order = new Order(); Calculation calculations = new Calculation(); ConsoleIO consoleIO = new ConsoleIO(); response.product = manager.GetProd(response); response.tax = manager.GetTax(response); Console.Clear(); response.Success = false; bool second = false; while (response.Success == false) { Extras.DisplayStarline(); string message = "Enter Order Date (MMDDYYYY):"; order.OrderDate = check.GetInput(message); message = "Enter the Customer's Name:"; order.CustomerName = check.GetInput(message); message = "Enter State (Ex: KY):"; order.State = check.GetInput(message).ToUpper(); ConsoleIO.DisplayProductInfo(response); message = "Enter Product Type:"; order.Type = check.GetInput(message).ToLower(); message = "Enter Area (square feet):"; order.Area = check.GetInputNum(message); Console.Clear(); response.order = order; order.OrderNumber = manager.GetNumber(order); order = calculations.GetTaxes(response); order = calculations.GetCosts(response); calculations.Calculate(order); response = manager.Add(order, second); if (response.Success == false) { ConsoleIO.FalseMessageAE(response); } } response.order = order; Console.WriteLine(); ConsoleIO.DisplayOrderInfo(order); string answer = consoleIO.YesOrNo(); ConsoleIO.DetermineAdd(answer, response.order); }
public static void DisplayProductInfo(AddEditResponse response) { int j = 0; foreach (var info in response.product) { Console.WriteLine($"Type: {response.product[j].ProductType}, Cost Per Squarefoot: {response.product[j].CostPerSquareFoot}, Labor Cost Per Squarefoot: {response.product[j].LaborCostPerSquareFoot}"); j++; } }
public Order GetCosts(AddEditResponse response) { foreach (var item in response.product) { if (Convert.ToString(item.ProductType).ToLower() == response.order.Type) { response.order.LaborCostPerSquareFoot = item.LaborCostPerSquareFoot; response.order.CostPerSquareFoot = item.CostPerSquareFoot; } } return(response.order); }
public async Task <AddEditResponse> UpdateRIDetail(UpdateRISiteRequest data) { var response = new AddEditResponse(); try { if (string.IsNullOrEmpty(data.riGovCode)) { response.Status = "false"; response.Message = "Please enter RI Code"; } else if (string.IsNullOrEmpty(data.name)) { response.Status = "false"; response.Message = "Please enter RI site"; } else if (data.chcId <= 0) { response.Status = "false"; response.Message = "Invalid chc"; } else if (data.phcId <= 0) { response.Status = "false"; response.Message = "Invalid phc"; } else if (data.scId <= 0) { response.Status = "false"; response.Message = "Invalid sc"; } else if (data.testingCHCId <= 0) { response.Status = "false"; response.Message = "Invalid testing chc"; } else { var addEditResponse = _saData.UpdateRIDetail(data); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public Order GetTaxes(AddEditResponse response) { Order order = response.order; foreach (var item in response.tax) { if (Convert.ToString(item.StateAbbreviation) == order.State) { order.TaxRate = item.TaxRate; } } response.order = order; return(response.order); }
public async Task <AddEditResponse> Add(RIRequest rData) { var response = new AddEditResponse(); try { if (rData.isActive.ToLower() != "true") { rData.isActive = "false"; } if (string.IsNullOrEmpty(rData.riGovCode)) { response.Status = "false"; response.Message = "Please enter ri gov code"; } else if (rData.phcId <= 0) { response.Status = "false"; response.Message = "Invalid PHC id"; } else if (rData.scId <= 0) { response.Status = "false"; response.Message = "Invalid SC id"; } else if (rData.ilrId <= 0) { response.Status = "false"; response.Message = "Invalid ILR id"; } else { var addEditResponse = _riData.Add(rData); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public async Task <AddEditResponse> Add(CHCRequest cData) { var response = new AddEditResponse(); try { if (cData.isActive.ToLower() != "true") { cData.isActive = "false"; } if (cData.isTestingFacility.ToLower() != "true") { cData.isTestingFacility = "false"; } if (string.IsNullOrEmpty(cData.chcGovCode)) { response.Status = "false"; response.Message = "Please enter chc gov code"; } else if (cData.districtId <= 0) { response.Status = "false"; response.Message = "Invalid district id"; } else if (cData.blockId <= 0) { response.Status = "false"; response.Message = "Invalid block id"; } else { var addEditResponse = _chcData.Add(cData); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public AddEditResponse Edit(Order order, bool second) { AddEditResponse response = new AddEditResponse(); EditOrderRules rules = new EditOrderRules(); List <Order> orders = _orderRepository.GetOrder(order.OrderDate); bool notEmpty = false; foreach (var ord in orders) { if (order.OrderDate == ord.OrderDate) { if (order.OrderNumber == order.OrderNumber) { order = ord; notEmpty = true; } } } if (second == true) { response = rules.EditOrder(order); if (response.Success == false) { Console.WriteLine($"Error: {response.Message}"); return(response); } orders[(order.OrderNumber - 1)] = response.order; _orderRepository.SaveOrder(orders); } if (notEmpty == false) { response.order = null; response.Message = "Enter a valid date & number"; } else { response.order = order; } return(response); }
public async Task <AddEditResponse> AddSCDetail(AddSCRequest data) { var response = new AddEditResponse(); try { if (string.IsNullOrEmpty(data.scGovCode)) { response.Status = "false"; response.Message = "Please enter sc gov code"; } else if (string.IsNullOrEmpty(data.name)) { response.Status = "false"; response.Message = "Please enter sc name"; } else if (data.chcId <= 0) { response.Status = "false"; response.Message = "Invalid chc"; } else if (data.phcId <= 0) { response.Status = "false"; response.Message = "Invalid phc"; } else { var addEditResponse = _saData.AddSCDetail(data); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public async Task <AddEditResponse> UpdateCHCDetail(UpdateCHCRequest data) { var response = new AddEditResponse(); try { if (string.IsNullOrEmpty(data.chcGovCode)) { response.Status = "false"; response.Message = "Please enter chc gov code"; } else if (string.IsNullOrEmpty(data.name)) { response.Status = "false"; response.Message = "Please enter chc name"; } else if (data.districtId <= 0) { response.Status = "false"; response.Message = "Invalid district"; } else if (data.blockId <= 0) { response.Status = "false"; response.Message = "Invalid block"; } else { var addEditResponse = _saData.UpdateCHCDetail(data); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public AddEditResponse Add(Order order, bool second) { AddOrdersRules rules = new AddOrdersRules(); AddEditResponse response = new AddEditResponse(); response.order = order; response = rules.AddOrder(response.order); if (response.Success == false) { return(response); } if (second == true) { List <Order> orders = _orderRepository.GetOrder(response.order.OrderDate); response.order.OrderNumber = (orders.Count + 1); orders.Add(response.order); _orderRepository.SaveOrder(orders); } return(response); }
public async Task <AddEditResponse> UpdateILRDetail(UpdateILRRequest data) { var response = new AddEditResponse(); try { if (string.IsNullOrEmpty(data.ilrCode)) { response.Status = "false"; response.Message = "Please enter ILR Code"; } else if (string.IsNullOrEmpty(data.name)) { response.Status = "false"; response.Message = "Please enter ILR Point"; } else if (data.chcId <= 0) { response.Status = "false"; response.Message = "Invalid chc"; } else { var addEditResponse = _saData.UpdateILRDetail(data); response.Status = "true"; response.Message = addEditResponse.message; } return(response); } catch (Exception e) { response.Status = "false"; response.Message = $"Unable to process - {e.Message}"; return(response); } }
public AddEditResponse AddOrder(Order order) { OrderManager manager = OrderManagerFactory.Create(); AddEditResponse response = new AddEditResponse(); response.product = manager.GetProd(response); response.tax = manager.GetTax(response); response.order = order; string date = ""; if (order.OrderDate.Length == 8) { string month = order.OrderDate.Remove(2); string year = order.OrderDate.Substring(4); string firstDay = order.OrderDate.Substring(2); string day = firstDay.Remove(2); date = month + "/" + day + "/" + year; } else { response.Success = false; response.Message = $"Make sure that the date is correct"; return(response); } DateTime orderDate = DateTime.Parse(date); DateTime dateToday = DateTime.Today; if (orderDate <= dateToday) { response.Success = false; response.Message = $"That date is not in the future."; return(response); } bool alphabet = response.order.CustomerName.All(c => Char.IsLetterOrDigit(c)); if (alphabet == false && response.order.CustomerName.All(c => c != '.' && c != ',')) { response.Success = false; response.Message = $"Make sure you've only entered a-z, 0-9, or commas and periods for Customer Name"; return(response); } bool productMatch = false; foreach (var product in response.product) { if (product.ProductType.ToLower() == order.Type) { productMatch = true; break; } productMatch = false; } if (productMatch == false) { response.Success = false; response.Message = $"Enter a product that we carry."; return(response); } bool stateMatch = false; foreach (var state in response.tax) { if (state.StateAbbreviation == order.State) { stateMatch = true; break; } stateMatch = false; } if (stateMatch == false) { response.Success = false; response.Message = $"Enter a state that we service."; return(response); } if (response.order.Area < 100) { response.Success = false; response.Message = $"Must be more that 100 square ft."; return(response); } response.Success = true; return(response); }
public AddEditResponse EditOrder(Order order) { AddEditResponse response = new AddEditResponse(); AddEditResponse responseOrg = new AddEditResponse(); OrderManager manager = OrderManagerFactory.Create(); response.product = manager.GetProd(response); response.tax = manager.GetTax(response); response.order = order; bool second = false; responseOrg = manager.Edit(order, second); bool alphabet = response.order.CustomerName.All(c => Char.IsLetterOrDigit(c) || response.order.CustomerName == ""); if (response.order.CustomerName == "") { order.CustomerName = responseOrg.order.CustomerName; } else if (alphabet == false && response.order.CustomerName.All(c => c != '.' && c != ',')) { response.Success = false; response.Message = $"Make sure you've only entered a-z, 0-9, or commas and periods for Customer Name"; return(response); } bool productMatch = false; if (response.order.Type == "") { order.Type = responseOrg.order.CustomerName; productMatch = true; } else { foreach (var product in response.product) { if (product.ProductType.ToLower() == order.Type.ToLower()) { productMatch = true; break; } else if (product.ProductType == "") { productMatch = true; break; } productMatch = false; } } if (productMatch == false) { response.Success = false; response.Message = $"Enter a product that we carry."; return(response); } bool stateMatch = false; if (response.order.State == "") { order.State = responseOrg.order.State; stateMatch = true; } else { foreach (var state in response.tax) { if (state.StateAbbreviation == order.State.ToUpper()) { stateMatch = true; break; } else if (order.State == "") { stateMatch = true; break; } stateMatch = false; } } if (stateMatch == false) { response.Success = false; response.Message = $"Enter a state that we service."; return(response); } if (response.order.Area == 0) { order.State = responseOrg.order.State; } else if (response.order.Area < 100) { response.Success = false; response.Message = $"Must be more that 100 square ft."; return(response); } response.Success = true; return(response); }
public List <Products> GetProd(AddEditResponse response) { response.product = _orderRepository.GetProducts(); return(response.product); }
public List <Taxes> GetTax(AddEditResponse response) { response.tax = _orderRepository.GetTaxes(); return(response.tax); }
public void Execute() { OrderManager manager = OrderManagerFactory.Create(); AddEditResponse response = new AddEditResponse(); Order order = new Order(); Calculation calculations = new Calculation(); ConsoleIO consoleIO = new ConsoleIO(); BlankCheck check = new BlankCheck(); response.Success = false; response.order = null; string message = ""; bool success = false; bool second = false; while (response.order == null) { Console.Clear(); Extras.DisplayStarline(); message = "Enter Order Date (MMDDYYYY):"; order.OrderDate = check.GetInput(message); message = "Enter Order Number:"; order.Area = check.GetInputNum(message); response = manager.Edit(order, second); if (response.order != null) { break; } else if (response.Success == false) { ConsoleIO.FalseMessageAE(response); } } while (response.Success == false) { response.product = manager.GetProd(response); response.tax = manager.GetTax(response); order = response.order; message = "Enter the Customer's Name:"; order.CustomerName = check.GetInput(message); message = "Enter State (Ex: KY):"; order.State = check.GetInput(message).ToUpper(); ConsoleIO.DisplayProductInfo(response); message = "Enter Product Type:"; order.Type = check.GetInput(message).ToLower(); message = "Enter Area (square feet):"; order.Area = check.GetInputNum(message); second = true; response = manager.Edit(order, second); if (response.Success == false) { ConsoleIO.FalseMessageAE(response); } } Console.Clear(); response.order = order; response.order = calculations.GetCosts(response); response.order = calculations.GetTaxes(response); calculations.Calculate(response.order); Console.WriteLine(); ConsoleIO.DisplayOrderInfo(response.order); string answer = consoleIO.YesOrNo(); ConsoleIO.DetermineEdit(answer, response.order); if (response.Success == false) { Console.WriteLine("Press any key to continue..."); Console.ReadKey(); EditWorkFlow editWorkFlow = new EditWorkFlow(); editWorkFlow.Execute(); } }
public static void FalseMessageAE(AddEditResponse response) { Console.WriteLine($"Error:{response.Message}"); Console.WriteLine("Press any key to continue..."); Console.ReadLine(); }