public void GetReceiptMethod() { GetInMemoryContext().Database.EnsureDeleted(); ReceiptBO prop1 = new ReceiptBO() { Title = "ost", Description = "beskrivelse", CreationDate = DateTime.MinValue, EmployeeId = 2, FileId = 3, CustomerId = 4 }; prop1 = GetMockService().Create(prop1); ReceiptBO prop2 = new ReceiptBO() { Title = "marmelade", Description = "en ny beskrivelse", CreationDate = DateTime.MinValue.Add(TimeSpan.FromMinutes(3)), EmployeeId = 3, FileId = 4, CustomerId = 5 }; prop2 = GetMockService().Create(prop2); ReceiptBO snurf = GetMockService().Get(prop1.Id); //Expected results Assert.IsNotNull(snurf); Assert.AreEqual("ost", snurf.Title); }
public void DeletePropositionMethod() { GetInMemoryContext().Database.EnsureDeleted(); var prop1 = new ReceiptBO() { Title = "nummerEt" }; var prop2 = new ReceiptBO() { Title = "nummerTo" }; var prop3 = new ReceiptBO() { Title = "nummerTre" }; var prop4 = new ReceiptBO() { Title = "nummerFire" }; prop1 = GetMockService().Create(prop1); prop2 = GetMockService().Create(prop2); prop3 = GetMockService().Create(prop3); prop4 = GetMockService().Create(prop4); Assert.IsNotNull(GetMockService().Get(prop3.Id)); prop3 = GetMockService().Delete(prop3.Id); Assert.IsNull(GetMockService().Get(prop3.Id)); }
public IActionResult Post([FromBody] ReceiptBO receipt) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(_facade.ReceiptService.Create(receipt))); }
public ReceiptBO Create(ReceiptBO bo) { using (var uow = _facade.UnitOfWork) { _newReceipt = uow.ReceiptRepository.Create(_recieptConv.Convert(bo)); uow.Complete(); return(_recieptConv.Convert(_newReceipt)); } }
public void save(ReceiptBO rec) { ReceiptDAL recDAL = new ReceiptDAL(); DateTime thisDay = DateTime.Today; rec.Receiptdate = thisDay.ToString("dd/MM/yyyy"); recDAL.save(rec); }
public void save(ReceiptBO rec) { FileStream fout = new FileStream("receiptdata.txt", FileMode.Append); StreamWriter sw = new StreamWriter(fout); sw.WriteLine(rec.Receiptid + ";" + rec.Receiptdate + ";" + rec.Orderid + ";" + rec.Amountpaid); sw.Close(); fout.Close(); }
public ReceiptBO Update(ReceiptBO bo) { using (var uow = _facade.UnitOfWork) { // gets receipt from DB that matches the id var receiptFromDB = uow.ReceiptRepository.Get(bo.Id); receiptFromDB.Title = bo.Title; receiptFromDB.Description = bo.Description; receiptFromDB.FileId = bo.FileId; uow.Complete(); return(_recieptConv.Convert(receiptFromDB)); } }
public IActionResult Put(int id, [FromBody] ReceiptBO receipt) { if (id != receipt.Id) { return(StatusCode(405, "Path id does not match customer ID json object")); } try { return(Ok(_facade.ReceiptService.Update(receipt))); } catch (InvalidOperationException e) { return(StatusCode(404, e.Message)); } }
public void CreateReceiptMethod() { GetInMemoryContext().Database.EnsureDeleted(); var snurf = new ReceiptBO() { Title = "ostemad", Description = "ostemad beskrivelse", CreationDate = DateTime.MinValue, EmployeeId = 2, FileId = 3, CustomerId = 4 }; GetMockService().Create(snurf); //Expected results Assert.IsNotNull(snurf); Assert.AreEqual("ostemad", snurf.Title); }
public Receipt Convert(ReceiptBO receipt) { if (receipt == null) { return(null); } { return(new Receipt() { Id = receipt.Id, Title = receipt.Title, Description = receipt.Description, CreationDate = receipt.CreationDate, Customer = _custConv.Convert(receipt.Customer), CustomerId = receipt.CustomerId, Employee = _empConv.Convert(receipt.Employee), EmployeeId = receipt.EmployeeId, FileId = receipt.FileId }); } }
public void UpdatePropositionMethod() { GetInMemoryContext().Database.EnsureDeleted(); var prop = new ReceiptBO() { Title = "Tit", Description = "Desc" }; var newProp = new ReceiptBO() { Title = "Title", Description = "Description" }; prop = GetMockService().Create(prop); Assert.AreEqual("Tit", prop.Title); prop = GetMockService().Update(GetMockService().Create(newProp)); Assert.AreEqual("Title", prop.Title); }
public void save(ReceiptBO rec) { String connectionstring = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Hassan\Desktop\POS-EAD-2\POS\MyDatabase.mdf;Integrated Security=True"; SqlConnection con = new SqlConnection(connectionstring); String query = "insert into receipt(date,orderid,amount) values(@date,@orderid,@am);"; SqlParameter p1 = new SqlParameter("orderid", rec.Orderid); SqlParameter p2 = new SqlParameter("date", rec.Receiptdate); SqlParameter p3 = new SqlParameter("am", rec.Amountpaid); SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.Add(p1); cmd.Parameters.Add(p2); cmd.Parameters.Add(p3); con.Open(); cmd.ExecuteNonQuery(); con.Close(); }
public void makepayment() { Console.Clear(); System.Console.WriteLine("Payment\n\n"); ReceiptBO rec = new ReceiptBO(); ReceiptBLL recB = new ReceiptBLL(); int recid = recB.readId(); DateTime thisDay = DateTime.Today; System.Console.Write("Enter SaleID: "); int saleid; String c = System.Console.ReadLine(); if (c.Length != 0) { saleid = int.Parse(c); } else { saleid = 0; } SaleBLL saleB = new SaleBLL(); SaleBO saleO = saleB.find(saleid); CustomerBLL custB = new CustomerBLL(); CustomerBO custO = custB.find(saleO.Custid); if (saleO.Orderid != 0) { double amountpaid = recB.amountpaid(saleid); double remain = saleO.Total - amountpaid; System.Console.WriteLine("Customer Name: " + custO.Name); System.Console.WriteLine("Total Sales Amount: " + saleO.Total); System.Console.WriteLine("Amount paid: " + amountpaid); System.Console.WriteLine("Remaining Amount: " + remain); System.Console.Write("Enter Amount: "); double amt; c = System.Console.ReadLine(); if (c.Length != 0) { amt = double.Parse(c); } else { amt = 0; } while (amt < 0 || amt > remain) { System.Console.Write("InValid Amount! Enter again: "); c = System.Console.ReadLine(); if (c.Length != 0) { amt = double.Parse(c); } else { amt = 0; } } if (remain > 0) { custO.Amount = custO.Amount - amt; custB.modify(custO); rec.Receiptid = recid; rec.Orderid = saleid; rec.Amountpaid = amt; recB.save(rec); } else { System.Console.WriteLine("Back to Main Menu..."); System.Threading.Thread.Sleep(2000); } } }
public void GetAllReceiptsMethod() { GetInMemoryContext().Database.EnsureDeleted(); CustomerBO cust1 = new CustomerBO() { Firstname = "ham her", Lastname = "Fuhlendorff", Address = "testvej1", CVR = 12312312, City = "Kolding", Email = "*****@*****.**", Phone = 12345678, ZipCode = 6000 }; cust1 = new CustomerService(GetDalFacadeMock(GetInMemoryContext()).Object).Create(cust1); CustomerBO cust2 = new CustomerBO() { Firstname = "ikke ham her", Lastname = "Meyer", Address = "testvej2222", CVR = 12312312, City = "Esbjerg", Email = "*****@*****.**", Phone = 12345678, ZipCode = 6700 }; EmployeeBO employee = new EmployeeBO() { Firstname = "Sigurd", Lastname = "Hansen", Username = "******", Password = "******", MacAddress = "dfkmgkldfnmg" }; employee = new EmployeeService(GetDalFacadeMock(this.GetInMemoryContext()).Object).Create(employee); cust2 = new CustomerService(GetDalFacadeMock(GetInMemoryContext()).Object).Create(cust2); ReceiptBO prop1 = new ReceiptBO() { Title = "qwe1", CustomerId = cust1.Id, EmployeeId = employee.Id }; prop1 = GetMockService().Create(prop1); ReceiptBO prop2 = new ReceiptBO() { Title = "qwe2", CustomerId = cust1.Id, EmployeeId = employee.Id }; prop2 = GetMockService().Create(prop2); ReceiptBO prop3 = new ReceiptBO() { Title = "qwe3", CustomerId = cust1.Id, EmployeeId = employee.Id }; prop3 = GetMockService().Create(prop3); ReceiptBO prop4 = new ReceiptBO() { Title = "qwe4", CustomerId = cust2.Id, EmployeeId = employee.Id }; prop4 = GetMockService().Create(prop4); ReceiptBO prop5 = new ReceiptBO() { Title = "qwe5", CustomerId = cust2.Id, EmployeeId = 1 }; prop5 = GetMockService().Create(prop5); ReceiptBO prop6 = new ReceiptBO() { Title = "qwe6", CustomerId = cust2.Id, EmployeeId = employee.Id }; prop6 = GetMockService().Create(prop6); List <ReceiptBO> allProps = GetMockService().GetAllById(cust1.Id); Assert.IsNotNull(allProps); Assert.AreEqual(3, allProps.Count); Assert.AreEqual(cust1.Firstname, allProps.Find(x => x.Title == "qwe3").Customer.Firstname); Assert.IsNull(allProps.Find(x => x.Title == "qwe4")); }