public ActionResult EditPartial(InternalMovementViewModel viewModel) { var user = _userProfileService.GetUser(User.Identity.Name); var fromStore = _hubService.GetAllStoreByUser(user); var commodities = _commodityService.GetAllParents(); var programs = _programService.GetAllProgramsForReport(); var units = _unitService.GetAllUnit(); var toStore = _hubService.GetAllStoreByUser(user); var reasons = _detailService.GetReasonByMaster(Master.Constants.REASON_FOR_INTERNAL_MOVMENT); var newViewModel = new InternalMovementViewModel(fromStore, commodities, programs, units, toStore, reasons); if (viewModel.QuantityInMt > _transactionService.GetCommodityBalanceForStack(viewModel.FromStoreId, viewModel.FromStackId, viewModel.CommodityId, viewModel.ShippingInstructionId, viewModel.ProjectCodeId)) { ModelState.AddModelError("QuantityInMt", "you dont have sufficent ammout to transfer"); return(View(newViewModel)); } if (viewModel.QuantityInMt <= 0) { ModelState.AddModelError("QuantityInMt", "You have nothing to transfer"); return(View(newViewModel)); } // _internalMovementService.AddNewInternalMovement(viewModel, user); _transactionService.SaveInternalMovementTrasnsaction(viewModel, user); return(RedirectToAction("Index", "InternalMovement")); }
public ActionResult EditPartial() { var user = _userProfileService.GetUser(User.Identity.Name); var fromStore = _hubService.GetAllStoreByUser(user); var commodities = _commodityService.GetAllParents(); var programs = _programService.GetAllProgramsForReport(); var units = _unitService.GetAllUnit(); var toStore = _hubService.GetAllStoreByUser(user); var reasons = _detailService.GetReasonByMaster(Master.Constants.REASON_FOR_INTERNAL_MOVMENT); var viewModel = new InternalMovementViewModel(fromStore, commodities, programs, units, toStore, reasons); return(View(viewModel)); }
public void CanDoCreatePostback() { //ACT var internalMovementViewModel = new InternalMovementViewModel { //TODO: Seed data before tesing }; var viewResult = _internalMovementController.Create(internalMovementViewModel) as ViewResult; //ASSERT Assert.NotNull(viewResult); var model = viewResult.Model; Assert.IsInstanceOf <InternalMovementViewModel>(model); }
public void Should_Create_InternalMovementViewModel_Object_ForCurentUser_and_Context() { var viewModel = new InternalMovementViewModel(repository, user); Assert.IsNotNull(viewModel); }
public void AddNewInternalMovement(InternalMovementViewModel viewModel, UserProfile user) { // _unitOfWork.TransactionRepository.SaveInternalMovementTrasnsaction(viewModel, user); }
public void Should_Add_InternalMovement() { InternalMovementViewModel actualViewModel = new InternalMovementViewModel(); actualViewModel.FromStoreId = 3; actualViewModel.SelectedDate = DateTime.Now; actualViewModel.FromStackId = 4; actualViewModel.ReferenceNumber = "Test/001/"; actualViewModel.CommodityId = 1; actualViewModel.ProgramId = 2; actualViewModel.ProjectCodeId = 33; actualViewModel.ShippingInstructionId = 46; actualViewModel.UnitId = 5; actualViewModel.QuantityInUnit = 100; actualViewModel.QuantityInMt = 200; actualViewModel.ToStoreId = 4; actualViewModel.ToStackId = 2; actualViewModel.ReasonId = 17; actualViewModel.Note = "Test transfer"; actualViewModel.ApprovedBy = "Mr Test"; ///expected values InternalMovement expectdInternalMovementModel = new InternalMovement(); expectdInternalMovementModel.PartitionID = 0; //expectdInternalMovementModel.TransactionGroupID expectdInternalMovementModel.TransferDate = actualViewModel.SelectedDate; expectdInternalMovementModel.ReferenceNumber = actualViewModel.ReferenceNumber; expectdInternalMovementModel.DReason = actualViewModel.ReasonId; expectdInternalMovementModel.Notes = actualViewModel.Note; expectdInternalMovementModel.ApprovedBy = actualViewModel.ApprovedBy; BLL.UserProfile actualUser = repository.UserProfile.GetUser("admin"); Transaction expectedFromStoreTrasactionModel = new Transaction(); expectedFromStoreTrasactionModel.PartitionID = 0; //expectedTrasactionModel.TransactionGroupID expectedFromStoreTrasactionModel.LedgerID = 2; expectedFromStoreTrasactionModel.HubOwnerID = actualUser.DefaultHub.HubOwner.HubOwnerID; //expectedTrasactionModel.AccountID = expectedFromStoreTrasactionModel.HubID = actualUser.DefaultHub.HubID; expectedFromStoreTrasactionModel.StoreID = actualViewModel.FromStoreId; expectedFromStoreTrasactionModel.Stack = actualViewModel.FromStackId; expectedFromStoreTrasactionModel.ProjectCodeID = actualViewModel.ProjectCodeId; expectedFromStoreTrasactionModel.ShippingInstructionID = actualViewModel.ShippingInstructionId; expectedFromStoreTrasactionModel.ProgramID = actualViewModel.ProgramId; //expectedFromStoreTrasactionModel.ParentCommodityID //expectedFromStoreTrasactionModel.CommodityID expectedFromStoreTrasactionModel.QuantityInMT = actualViewModel.QuantityInMt; expectedFromStoreTrasactionModel.QuantityInUnit = actualViewModel.QuantityInUnit; expectedFromStoreTrasactionModel.UnitID = actualViewModel.UnitId; Transaction expectedToStoreTrasactionModel = new Transaction(); expectedToStoreTrasactionModel.PartitionID = 0; //expectedTrasactionModel.TransactionGroupID expectedToStoreTrasactionModel.LedgerID = 2; expectedToStoreTrasactionModel.HubOwnerID = actualUser.DefaultHub.HubOwner.HubOwnerID; //expectedTrasactionModel.AccountID = expectedToStoreTrasactionModel.HubID = actualUser.DefaultHub.HubID; expectedToStoreTrasactionModel.StoreID = actualViewModel.FromStoreId; expectedToStoreTrasactionModel.Stack = actualViewModel.FromStackId; expectedToStoreTrasactionModel.ProjectCodeID = actualViewModel.ProjectCodeId; expectedToStoreTrasactionModel.ShippingInstructionID = actualViewModel.ShippingInstructionId; expectedToStoreTrasactionModel.ProgramID = actualViewModel.ProgramId; //expectedFromStoreTrasactionModel.ParentCommodityID //expectedFromStoreTrasactionModel.CommodityID expectedToStoreTrasactionModel.QuantityInMT = actualViewModel.QuantityInMt; expectedToStoreTrasactionModel.QuantityInUnit = actualViewModel.QuantityInUnit; expectedToStoreTrasactionModel.UnitID = actualViewModel.UnitId; //var redirectToRouteResult = (RedirectToRouteResult) new InternalMovementController().Create(actualViewModel); //repository.InternalMovement.AddNewInternalMovement(actualViewModel, actualUser); repository.Transaction.SaveInternalMovementTrasnsaction(actualViewModel, actualUser); //CollectionAssert.Contains(repository.Transaction.GetAll(), expectedFromStoreTrasactionModel); //CollectionAssert.Contains(repository.InternalMovement.GetAll(), expectdInternalMovementModel); }