public PurchaseServiceTests() { purchaseRepositoryMock = new Mock <IPurchaseRepository>(); adapterFactoryMock = new Mock <IAdapterFactory>(); purchaseService = new PurchaseService(purchaseRepositoryMock.Object, adapterFactoryMock.Object); }
public ConfirmBaseController() { purchaseService = ServiceLocator.GetService <PurchaseService>(); service = ServiceLocator.GetService <ConfirmationService>(); MAILService = ServiceLocator.GetService <PaskolEmailService>(); musicSrv = ServiceLocator.GetService <MusicService>(); }
public async Task Get_OutOfBounds() { // Arrange var id = 6; var client = SetupMock_PurchaseDto(id); var config = new Mock <IConfiguration>(); client.BaseAddress = new Uri("http://localhost:12324/"); config.SetupGet(s => s["PurchasesUrl"]).Returns("http:localhost:12324/"); var purchaseRepo = new FakePurchaseRepository(TestData.Purchases().Select(p => new Purchase { AccountId = p.AccountId, Id = p.Id, ProductId = p.ProductId }).ToList()); var service = new PurchaseService(null, config.Object, new NullLogger <PurchaseService>(), purchaseRepo) { HttpClient = client }; // Act var result = await service.GetPurchase(id); // Assert Assert.IsNull(result); }
public async void Should_CalculateAndComparePurchaseData_With_PreCalculatedPurchaseData(PurchaseDataModel purchaseData) { // Arrange IPurchaseService purchaseService = new PurchaseService(); // Act var resultGrossAmount = await purchaseService.CalculatePurchaseInfo(new PurchaseDataModel { VATRate = purchaseData.VATRate, GrossAmount = purchaseData.GrossAmount }); var resultVATAmount = await purchaseService.CalculatePurchaseInfo(new PurchaseDataModel { VATRate = purchaseData.VATRate, VATAmount = purchaseData.VATAmount }); var resultNetAmount = await purchaseService.CalculatePurchaseInfo(new PurchaseDataModel { VATRate = purchaseData.VATRate, NetAmount = purchaseData.NetAmount }); // Assert Assert.Equal(purchaseData.VATRate, resultGrossAmount.VATRate); Assert.Equal(purchaseData.GrossAmount, resultGrossAmount.GrossAmount); Assert.Equal(purchaseData.VATAmount, resultGrossAmount.VATAmount); Assert.Equal(purchaseData.NetAmount, resultGrossAmount.NetAmount); Assert.Equal(purchaseData.VATRate, resultVATAmount.VATRate); Assert.Equal(purchaseData.GrossAmount, resultVATAmount.GrossAmount); Assert.Equal(purchaseData.VATAmount, resultVATAmount.VATAmount); Assert.Equal(purchaseData.NetAmount, resultVATAmount.NetAmount); Assert.Equal(purchaseData.VATRate, resultNetAmount.VATRate); Assert.Equal(purchaseData.GrossAmount, resultNetAmount.GrossAmount); Assert.Equal(purchaseData.VATAmount, resultNetAmount.VATAmount); Assert.Equal(purchaseData.NetAmount, resultNetAmount.NetAmount); }
public BaseViewModel() { _vimeoApiService = new VimeoAPIService(); _userService = new UserService(); _accountService = new AccountService(); _purchaseService = new PurchaseService(); }
public ActionResult DeleteEmlead(List <bool> Check, List <int> ID, List <short> RowVersion) { svPurchase = new PurchaseService(); int CountAssignLead = 0; int CountEmLead = 0; svPurchase.DelData <b2bEmLead>(Check, ID, RowVersion, "EmLeadID"); if (svPurchase.IsResult) { for (int i = 0; i < ID.Count(); i++) { if (Check[i] == true) { var countEmCompLead = svPurchase.CountData <b2bEmCompanyLead>("AssignLeadID,AssignLeadName", "IsDelete = 0 AND EmLeadID =" + ID[i]); if (countEmCompLead > 0) { var EmCompLead = svPurchase.SelectData <b2bEmCompanyLead>("*", "IsDelete = 0 AND EmLeadID =" + ID[i]); svPurchase.DeleteData <b2bEmCompanyLead>(EmCompLead, "EmCompLeadID", ""); } } } CountAssignLead = svPurchase.CountData <b2bAssignLead>("AssignLeadID,AssignLeadName", "IsDelete = 0"); CountEmLead = svPurchase.CountData <b2bEmLead>("EmLeadID,EmLeadName", "IsDelete = 0"); } return(Json(new { Result = svPurchase.IsResult, CountAssignLead = CountAssignLead, CountEmLead = CountEmLead })); }
public ActionResult List(FormCollection form) { svPurchase = new PurchaseService(); string sqlWhere = ""; string sqlSelect = ""; SelectList_PageSize(); SetPager(form); string pagetype = Request.Cookies["PurchasePageAction"].Value; if (pagetype == "emLead") { sqlWhere = "IsDelete = 0"; sqlSelect = "EmLeadID,EmLeadCode,EmLeadName,EmLeadKeyword,Remark,LeadCount,IsMark,IsImportance,LeadFolderID,CreatedDate,RowVersion"; var emLeads = svPurchase.SelectData <b2bEmLead>(sqlSelect, sqlWhere, "CreatedDate DESC", (int)ViewBag.PageIndex, (int)ViewBag.PageSize); ViewBag.EmLeads = emLeads; ViewBag.TotalPage = svPurchase.TotalPage; ViewBag.TotalRow = svPurchase.TotalRow; ViewBag.hidPageType = pagetype; return(PartialView("UC/ImportEmLeadGrid")); } else { sqlWhere = "IsDelete = 0"; sqlSelect = "AssignLeadID,AssignLeadName,ToContactName,ToContactEmail,ToContactTel,OtherEmail,IsDefaultLead,LeadFolderID,CreatedDate,RowVersion"; var AssignLeads = svPurchase.SelectData <b2bAssignLead>(sqlSelect, sqlWhere, "CreatedDate DESC", (int)ViewBag.PageIndex, (int)ViewBag.PageSize); ViewBag.AssignLeads = AssignLeads; ViewBag.TotalPage = svPurchase.TotalPage; ViewBag.TotalRow = svPurchase.TotalRow; ViewBag.hidPageType = pagetype; return(PartialView("UC/AssignLeadGrid")); } }
private void button2_Click(object sender, EventArgs e) { if (PriceBox.Text == string.Empty || QuantityBox.Text == string.Empty || dateTimePicker1.Text == string.Empty || comboBox1.Text == string.Empty) { MessageBox.Show("Please Fillup All The Text Fields"); } else { double tp = (Double.Parse(PriceBox.Text) * Convert.ToInt16(QuantityBox.Text)); PurchaseService ps = new PurchaseService(); int result = ps.Insert(new Purchase() { Item_Name = NameBox.Text, Quantity = Convert.ToInt16(QuantityBox.Text), Price = Double.Parse(PriceBox.Text), Date = Convert.ToDateTime(dateTimePicker1.Value), Cat_Id = Convert.ToInt32(comboBox1.Text), Total_price = tp }); if (result > 0) { InventoryService inservice = new InventoryService(); int insert = inservice.Insert(new Inventory() { ProductName = NameBox.Text, Quantity = Convert.ToSingle(QuantityBox.Text) }); MessageBox.Show(" added."); } else { MessageBox.Show("Error"); } } }
private void b_Total_Click(object sender, EventArgs e) { PurchaseService PService = new PurchaseService(); dataGridView1.DataSource = PService.GetById(comboBox1.Text, dateTimePicker1.Value, dateTimePicker2.Value); Sum(); }
public async Task <Tuple <List <HistoryViewModel>, int> > GetHistory(Rm rm) { PurchaseService service = new PurchaseService(new BaseRepository <Purchase>(Repository.Db)); PurchaseRequestModel request = new PurchaseRequestModel("") { ShopId = rm.ShopId, ParentId = rm.ParentId, Page = -1 }; Tuple <List <PurchaseViewModel>, int> result = await service.SearchAsync(request); List <HistoryViewModel> viewModels = result.Item1.ConvertAll(x => new HistoryViewModel(x)).ToList(); var transactionService = new BaseService <Transaction, TransactionRequestModel, TransactionViewModel>(new BaseRepository <Transaction>(Repository.Db)); Tuple <List <TransactionViewModel>, int> transactionTuple = await transactionService.SearchAsync( new TransactionRequestModel("", "Modified", "False") { ShopId = rm.ShopId, ParentId = rm.ParentId, Page = -1 }); List <HistoryViewModel> models = transactionTuple.Item1.ConvertAll(x => new HistoryViewModel(x) { Type = "Payment", PurchaseId = x.ParentId }).ToList(); viewModels.AddRange(models); List <HistoryViewModel> merged = viewModels.OrderByDescending(x => x.Date).ToList(); return(new Tuple <List <HistoryViewModel>, int>(merged, merged.Count)); }
public EntryPageViewModel() { _purchaseService = new PurchaseService(); _hasGiAndNoGiPackage = false; _hasGiPackage = false; _hasNoGiPackage = false; }
public ActionResult CreateEmLead() { RememberURL(); if (!CheckIsLogin()) { return(Redirect(res.Pageviews.PvMemberSignIn)); } else { GetStatusUser(); if (LogonServiceType == 9) { svAddress = new AddressService(); svBizType = new BizType.BizTypeService(); svPurchase = new PurchaseService(); SetPager(); CountLead(); ViewBag.EmLeadCode = svPurchase.GenLeadCode(0, 2); ViewBag.actionEmLead = 0; return(View()); } else { return(Redirect(PathHome)); } } }
public PurchaseDTO Pay(int clientId, int purchaseId) { ClientService.CheckCredentials(clientId); Purchase purchase = PurchaseService.FindEntity(purchaseId); if (purchase.PayingTime != null) { throw new AppException("Already payed", 400); } decimal amount = purchase.Amount; ClientAccount source = ClientService.GetAccount(clientId); if (amount > source.Balance) { throw new AppException("Not enough money", 400); } TraderAccount target = TraderService.GetAccount(purchase.CommercialLink.TraderId); PaymentMonitor.Remove(purchaseId); source.Balance -= amount; target.Balance += amount; purchase.PayingTime = DateTime.Now; ClientAccountService.Update(source); TraderAccountService.Update(target); purchase = PurchaseService.Update(purchase); return(PurchaseService.EntityToDTO(purchase)); }
public async Task GetAll_Success() { // Arrange var client = SetupMock_ListPurchaseDto(); var config = new Mock <IConfiguration>(); client.BaseAddress = new Uri("http://localhost:12324/"); config.SetupGet(s => s["PurchasesUrl"]).Returns("http:localhost:12324/"); var purchaseRepo = new FakePurchaseRepository(TestData.Purchases().Select(p => new Purchase { AccountId = p.AccountId, Id = p.Id, ProductId = p.ProductId }).ToList()); var service = new PurchaseService(null, config.Object, new NullLogger <PurchaseService>(), purchaseRepo) { HttpClient = client }; // Act var result = await service.GetAll(); // Assert Assert.IsNotNull(result); foreach (var purchase in result) { var testItem = TestData.Purchases().FirstOrDefault(p => p.Id == purchase.PurchaseRef); Assert.AreEqual(testItem.Id, purchase.PurchaseRef); Assert.AreEqual(testItem.AccountId, purchase.AccountId); } }
private async void btnRegisterPurchase_Click(object sender, EventArgs e) { try { if (this.txtRuc.Text == string.Empty) { throw new ArgumentNullException("Debe ingresar el RUC del proveedor."); } if (this.txtRuc.TextLength != 11) { throw new ArgumentException("El RUC debe tener exacntamente 11 digitos"); } if (this.cartDetailPurchase.getCount() == 0) { throw new ArgumentException("Debe registrar como minimo 1 producto para realizar la COMPRA"); } Purchase purchase = new Purchase { ruc = this.txtRuc.Text, detailPurchaseList = this.cartDetailPurchase.ToDetailPurchaseList(), total = this.cartDetailPurchase.total }; Purchase resultPurchase = await PurchaseService.RegisterPurchase(purchase); FormSuccess.ConfirmationForm("REGISTRADO"); this.ResetRegisterConfiguration(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected async override Task OnInitializedAsync() { Vendors = await VendorService.GetAllVendorsAsync(); if (IsEdit) { Purchase = await PurchaseService.GetOnePurchaseAsync((Guid)Id); CreatePurchase = new CreatePurchaseRequest() { Id = Purchase.Id, VendorId = Purchase.VendorId, Date = Purchase.Date, ReferenceNumber = Purchase.ReferenceNumber }; } else { CreatePurchase = new CreatePurchaseRequest { Id = (Guid)Id, Date = DateTime.Today }; } }
private PurchaseService CreatePurchaseService() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new PurchaseService(userId); return(service); }
public async Task CreatePurchaseByUserIdTests() { //Arrange var mapperConfig = new MapperConfiguration(x => x.AddProfile(new MappingProfile())); var mapper = mapperConfig.CreateMapper(); var cartService = new CartService(this.context, mapper); var purchaseService = new PurchaseService(this.context, cartService, mapper); var user = new User { UserName = "******", Email = "*****@*****.**", PhoneNumber = "0 888 888 888", RegisteredOn = DateTime.UtcNow, }; await this.context.Users.AddAsync(user); await this.context.SaveChangesAsync(); var address = "newAddress"; //Act Assert.Equal(0, this.context.Purchases.Count()); await purchaseService.CreatePurchaseByUserId(user, address); await purchaseService.CreatePurchaseByUserId(user, address + "new"); //Assert Assert.Equal(2, this.context.Purchases.Count()); }
public void UpdateEmLead(FormCollection form) { svPurchase = new PurchaseService(); var EmLead = svPurchase.SelectData <b2bEmLead>("*", "IsDelete = 0 AND EmLeadID =" + form["hidEmLeadID"]).First(); EmLead.EmLeadName = form["txtLeadName"]; EmLead.EmLeadKeyword = form["txtKeyword"]; EmLead.Remark = form["txtRemark"]; EmLead.LeadCount = DataManager.ConvertToShort(form["hidCountCompLead"]); EmLead = svPurchase.SaveData <b2bEmLead>(EmLead, "EmLeadID"); if (svPurchase.IsResult) { #region Insert New EmCompLead if (!string.IsNullOrEmpty(form["hidAllSupplierCompID"])) { int EmLeadID = EmLead.EmLeadID; var supplierCompID = form["hidAllSupplierCompID"]; string[] subSupplierCompID = supplierCompID.Split(','); for (int i = 0; i < subSupplierCompID.Length; i++) { var b2bEmCompanyLead = new b2bEmCompanyLead(); int SupplierCompID = DataManager.ConvertToInteger(subSupplierCompID[i]); b2bEmCompanyLead.EmLeadID = EmLeadID; b2bEmCompanyLead.CompID = SupplierCompID; b2bEmCompanyLead.EmCompLeadCode = svPurchase.GenLeadCode(SupplierCompID, 3); svPurchase.InsertEmCompanyLead(b2bEmCompanyLead); } } #endregion } }
public ActionResult ImportEmLead(FormCollection form) { svPurchase = new PurchaseService(); SetPager(form); if (ViewBag.TextSearch != null && ViewBag.TextSearch != "") { string sqlWhere = "EmLeadKeyword LIKE N'" + ViewBag.TextSearch + "%' AND IsDelete = 0"; string sqlSelect = "EmLeadID,EmLeadCode,EmLeadName,EmLeadKeyword,Remark,LeadCount,LeadFolderID"; var emLeads = svPurchase.SelectData <b2bEmLead>(sqlSelect, sqlWhere, "CreatedDate DESC", ViewBag.PageIndex, ViewBag.PageSize); ViewBag.EmLeads = emLeads; ViewBag.TotalPage = svPurchase.TotalPage; ViewBag.TotalRow = svPurchase.TotalRow; } else { string sqlWhere = "IsDelete = 0"; string sqlSelect = "EmLeadID,EmLeadCode,EmLeadName,EmLeadKeyword,Remark,LeadCount,LeadFolderID"; var emLeads = svPurchase.SelectData <b2bEmLead>(sqlSelect, sqlWhere, "CreatedDate DESC", ViewBag.PageIndex, ViewBag.PageSize); ViewBag.EmLeads = emLeads; ViewBag.TotalPage = svPurchase.TotalPage; ViewBag.TotalRow = svPurchase.TotalRow; } return(PartialView("UC/ImportEmLeadGrid")); }
public void PurchaseServiceCanAffordProductWorksCorrectlyWhenInsufficientFundsAreIn() { //These could be mocked out, but since they are simple in memory //instaces there is no point. ISessionService sessionService = new InMemorySessionService(); IItemRepository itemRepository = new ItemRepository(); IPurchaseService purchaseService = new PurchaseService(itemRepository, sessionService); Guid sessionId = Guid.NewGuid(); double tallyValue = 0.5; sessionService.StoreCurrentTally(sessionId, tallyValue); //If sufficient money is in a session, the item price minus the session tally is returned. double checkResult = tallyValue - itemRepository.GetItem(0).Price; double result = purchaseService.CanAffordProduct(sessionId, 0); Assert.True(result < 0); Assert.True(checkResult == result); //Make sure the session hasn't been modified Assert.True(sessionService.GetStoredTally(sessionId) == tallyValue); }
public ActionResult CreateLead() { RememberURL(); if (!CheckIsLogin()) { return(Redirect(res.Pageviews.PvMemberSignIn)); } else { GetStatusUser(); if (LogonServiceType == 9) { svAddress = new AddressService(); svBizType = new BizType.BizTypeService(); svPurchase = new PurchaseService(); SetPager(); CountLead(); ViewBag.AssignLeadCode = svPurchase.GenLeadCode(0, 1); ViewBag.Provinces = svAddress.GetProvinceAll().ToList(); ViewBag.Biztypes = svBizType.GetBiztype().ToList(); ViewBag.setEmLeadID = ""; return(View()); } else { return(Redirect(PathHome)); } } }
public int SavePurchaseService(PurchaseService purServ) { int uniqueID = 0; TEPurchase_Service serv = new TEPurchase_Service(); serv.Purchasing_Order_Number = purServ.PurchasingOrderNumber; serv.LongText = purServ.LongText; serv.Item_Number = purServ.ItemNumber; serv.Line_item_number = purServ.LineItemNumber; serv.Activity_Number = purServ.ActivityNumber; serv.Short_Text = purServ.ShortText;//shortdescription //serv.OrderQuantity = purServ.OrderQuantity; serv.Unit_Measure = purServ.UnitMeasure; serv.Gross_Price = purServ.GrossPrice; serv.Net_Price = purServ.NetPrice; serv.Actual_Qty = purServ.ActualQuantity; serv.line_item = purServ.LineItem; serv.WBS_Element = purServ.WBS_Element; //materialWBS serv.Fund_Center = purServ.Fund_Center; //FundcenterID serv.Package_number = purServ.Package_number; serv.Commitment_item = purServ.Commitment_item; serv.Seq_No_Acc_Ass_ESKN = purServ.Seq_No_Acc_Ass_ESKN; serv.Line_Number_INTROW = purServ.Line_Number_INTROW; //.SAC_Code = purServ.SAC_Code; db.TEPurchase_Service.Add(serv); db.SaveChanges(); if (serv.Uniqueid != 0) { uniqueID = serv.Uniqueid; } return(uniqueID); }
public TelaCompra() { InitializeComponent(); ConfigurarCombobox(); ConfigurarDatagrid(); purchaseService = new PurchaseService(); productService = new ProductService(); }
public delegateController(IManageRepository _manageRepository, IBomRepository _bomrepository, IPurchaseRepository _bomRepository, IStockInRepository _stockinrepository, IStockOutRepository _stockoutrepository) { manageService = new ManageService(_manageRepository); bomService = new BomService(_bomrepository); stockoutService = new StockOutService(_stockoutrepository); stockinService = new StockInService(_stockinrepository); purchaseService = new PurchaseService(_bomRepository); }
public void DeleteEmCompLead(int EmCompLeadID) { svPurchase = new PurchaseService(); var EmCompLead = svPurchase.SelectData <b2bEmCompanyLead>("*", "IsDelete = 0 AND EmCompLeadID =" + EmCompLeadID); svPurchase.DeleteData <b2bEmCompanyLead>(EmCompLead, "EmCompLeadID", ""); }
PurchaseService purchService; //naor public RealBridge() { appointService = new Appoitment_Service(); userService = new UserService(); sysService = new System_Service("Admin", "Admin"); StoreService = new StoreService(); purchService = new PurchaseService(); }
public IActionResult Buy(PurchaseBindingModel model, HttpResponse response) { PurchaseService service = new PurchaseService(Data.Data.Context); service.AddPurchase(model); Redirect(response, "/home/index"); return(null); }
public ActionResult Edit(Guid id) { ViewBag.EmployeeList = EmployeeService.FindNormalList(); var model = PurchaseService.Get(id); return(View("Edit", model)); }
public PurchaseServiceTest() { _purchase = new Purchase(_supplier, discount); _purchaseService = new PurchaseService(_purchaseRepo.Object, _supplierRepo.Object, _itemRepo.Object); _purchaseCreate = new PurchaseCreateDTO(); _purchaseDetailCreate = new PurchaseDetailCreateDTO(); _supplier = new Supplier(name, address, email, phone); }
public void FillClient(PurchaseService.ArrayOfString info) { clientLogin = info[0]; password = info[1]; name = info[2]; firstName = info[3]; inscriptionDate = DateTime.Parse(info[4]); sold=Convert.ToDouble(info[5]); }