public void ExistsByIdTestIsTrue() { // Arrange stockAdjustmentRepository.Save(new StockAdjustment() { StockAdjustmentId = "DOREPOTEST", CreatedDateTime = DateTime.Now, }); // Act var result = stockAdjustmentRepository.ExistsById("DOREPOTEST"); // Assert Assert.IsTrue(result); }
public void CleanAllObjectCreated() { string[] ids = new string[] { "he01", "he02", "he03", "he04", "he05", "he07", "he08", "he09" }; foreach (string id in ids) { StockAdjustment sa = stockAdjustmentRepository.FindById(id); if (sa != null) { stockAdjustmentRepository.Delete(sa); } } if (itemRepository.FindById("he06") != null) { itemRepository.Delete(itemRepository.FindById("he06")); } if (inventoryRepository.FindById("he06") != null) { inventoryRepository.Delete(inventoryRepository.FindById("he06")); } if (stockAdjustmentRepository.ExistsById("ADJAPPROVETEST")) { stockAdjustmentRepository.Delete(stockAdjustmentRepository.FindById("ADJAPPROVETEST")); } }
/// <summary> /// Approve stock adjustment written for mobile. /// </summary> /// <param name="stockAdjustmentId"></param> /// <param name="email"></param> public void ApproveStockAdjustment(string stockAdjustmentId, string email) { var userService = new UserService(context); if (!stockAdjustmentRepository.ExistsById(stockAdjustmentId)) { throw new ArgumentException("Stock Adjustment does not exist"); } StockAdjustment stockAdjustment = stockAdjustmentRepository.FindById(stockAdjustmentId); if (stockAdjustment.Status.StatusId == 5 || stockAdjustment.Status.StatusId == 6) { throw new ArgumentException("Stock Adjustment already approved/rejected"); } stockAdjustment.Status = statusRepository.FindById(6); if (userService.FindRolesByEmail(email).Contains("StoreManager")) { stockAdjustment.ApprovedByManager = userService.FindUserByEmail(email); } else if (userService.FindRolesByEmail(email).Contains("StoreSupervisor")) { stockAdjustment.ApprovedBySupervisor = userService.FindUserByEmail(email); } stockAdjustmentRepository.Save(stockAdjustment); //update item inventory stockAdjustment.StockAdjustmentDetails.ForEach(detail => stockMovementService.CreateStockMovement(detail)); // Send notification Notification approved = new NotificationService(context).CreateApproveStockAdjustmentNotification(stockAdjustment, stockAdjustment.CreatedBy); new NotificationApiController() { context = context }.SendNotification(approved.NotificationId.ToString()); new NotificationApiController() { context = context }.SendEmail(approved.NotificationId.ToString()); }
public void TestCleanUp() { var stockAdjustmentRepository = new StockAdjustmentRepository(context); if (saService.FindAllStockAdjustment().Where(x => x.Remarks == "THIS IS A TEST").FirstOrDefault() != null) { saRepository.Delete(saService.FindAllStockAdjustment().Where(x => x.Remarks == "THIS IS A TEST").FirstOrDefault()); } if (stockAdjustmentRepository.ExistsById("ADJCONTROLTEST")) { stockAdjustmentRepository.Delete(stockAdjustmentRepository.FindById("ADJCONTROLTEST")); } }
public void TestCleanup() { if (stockAdjustmentDetailRepository.ExistsById("SADREPOTEST", "E030")) { stockAdjustmentDetailRepository.Delete(stockAdjustmentDetailRepository.FindById("SADREPOTEST", "E030")); } if (stockAdjustmentDetailRepository.ExistsById("SADREPOTEST", "P030")) { stockAdjustmentDetailRepository.Delete(stockAdjustmentDetailRepository.FindById("SADREPOTEST", "P030")); } if (stockAdjustmentRepository.ExistsById("SADREPOTEST")) { stockAdjustmentRepository.Delete(stockAdjustmentRepository.FindById("SADREPOTEST")); } }