public static async Task ViewReturns() { try { using (IReturnBL ReturnBL = new ReturnBL()) { List <Return> onlineReturns = await ReturnBL.GetAllReturnsBL(); WriteLine("Returns:"); if (onlineReturns != null && onlineReturns.Count > 0) { WriteLine("#\tPurpose\tQuantityOfReturn\\tCreated\tModified"); int serialNo = 0; foreach (var onlineReturn in onlineReturns) { serialNo++; WriteLine($"{serialNo}\t{onlineReturn.Purpose}\t{onlineReturn.QuantityOfReturn}\t{onlineReturn.CreationDateTime}\t{onlineReturn.LastModifiedDateTime}"); } } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
public async Task OnlineReturnListCanNotBeEmpty() { //Arrange bool isDisplayed = false; string errorMessage = null; //Act try { ReturnBL onlineReturnBL = new ReturnBL(); List <Return> onlineReturnList = await onlineReturnBL.GetAllReturnsBL(); if (onlineReturnList.Count < 1) { isDisplayed = true; } } catch (Exception ex) { isDisplayed = false; errorMessage = ex.Message; } finally { //Assert Assert.IsFalse(isDisplayed, errorMessage); } }
public async Task GetAllValidOnlineReturns() { //Arrange ReturnBL onlineReturnBL = new ReturnBL(); Return onlineReturn = new Return() { OrderNumber = 20, ProductNumber = 4, QuantityOfReturn = 5, Purpose = PurposeOfReturn.DefectiveProduct }; await onlineReturnBL.AddReturnBL(onlineReturn); bool isDisplayed = false; string errorMessage = null; //Act try { List <Return> onlineReturnList = await onlineReturnBL.GetAllReturnsBL(); if (onlineReturnList.Count > 0) { isDisplayed = true; } } catch (Exception ex) { isDisplayed = false; errorMessage = ex.Message; } finally { //Assert Assert.IsTrue(isDisplayed, errorMessage); } }
public static async Task DeleteReturn() { try { using (IReturnBL ReturnBL = new ReturnBL()) { Write("OnlineReturn #: "); bool isNumberValid = int.TryParse(ReadLine(), out int serialNo); if (isNumberValid) { serialNo--; List <Return> onlineReturns = await ReturnBL.GetAllReturnsBL(); if (serialNo <= onlineReturns.Count - 1) { Return onlineReturn = onlineReturns[serialNo]; Write("Are you sure? (Y/N): "); string confirmation = ReadLine(); if (confirmation.Equals("Y", StringComparison.OrdinalIgnoreCase)) { bool isDeleted = await ReturnBL.DeleteOnlineReturnBL(onlineReturn.OnlineReturnID); if (isDeleted) { WriteLine("OnlineReturn Deleted"); } } } else { WriteLine($"Invalid OnlineReturn #.\nPlease enter a number between 1 to {onlineReturns.Count}"); } } else { WriteLine($"Invalid number."); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
public static async Task UpdateOnlineReturn() { try { using (IReturnBL onlineReturnsBL = new ReturnBL()) { Write("OnlineReturn #: "); bool isNumberValid = int.TryParse(ReadLine(), out int serial); if (isNumberValid) { serial--; List <Return> onlineReturns = await onlineReturnsBL.GetAllReturnsBL(); if (serial <= onlineReturns.Count - 1) { Return onlineReturn = onlineReturns[serial]; WriteLine("Purpose of Return:\n1. UnsatiSfactoryProduct\n2. WrongProductShipped\n3. WrongProductOrdered\n4. DefectiveProduct "); bool isPurposeValid = int.TryParse(ReadLine(), out int purpose); Write("QuantityOfReturn: "); onlineReturn.QuantityOfReturn = Convert.ToInt32(ReadLine()); bool isUpdated = await onlineReturnsBL.UpdateReturnBL(onlineReturn); if (isUpdated) { WriteLine("OnlineReturn Updated"); } } else { WriteLine($"Invalid OnlineReturn #.\nPlease enter a number between 1 to {onlineReturns.Count}"); } } else { WriteLine($"Invalid number."); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }