public void GetById_Customer_Test() { var result = _customerLogic.GetById(1); result.Should().NotBeNull(); result.Id.Should().BeGreaterThan(0); }
public void GetById_Customer_Test() { var result = _customerLogic.GetById(1); result.Should().NotBeNull(); //Validación que no devulva null result.Id.Should().BeGreaterThan(0); //Validación que el Id sea mayor a 0 }
public ActionResult UpdateCustomer(InvoiceCustomerViewModel customerViewModel) { if (customerViewModel.Id != 0) { var customer = customerLogic.GetById(customerViewModel.Id); customerViewModel.Customer = customer; return(View(customerViewModel)); } else { return(RedirectToAction("Customer")); } }
// GET: CompanyStatistics public ActionResult Statistics() { var companyStats = companyStatisticsLogic.GetTop3Customers(); for (int i = 0; i < companyStats.TopCustomers.Count; i++) { var totalprice = companyStats.TopCustomers[i].TotalPriceOfAllInvoices; companyStats.TopCustomers[i] = customerLogic.GetById(Convert.ToInt32(companyStats.TopCustomers[i].ID)); companyStats.TopCustomers[i].TotalPriceOfAllInvoices = totalprice; } return(View("Statistics", companyStats)); }
//TODO: test weghalen public void test(string id) { InvoicePdfCreator creator = new InvoicePdfCreator(); Invoice invoice = invoiceLogic.GetById(Convert.ToInt32(id)); Customer customer = customerLogic.GetById(invoice.Customer.ID); Invoice invoiceTasks = invoiceLogic.GetTasksOnInvoice(invoice); invoice.Customer = customer; invoice.Tasks = invoiceTasks.Tasks; try { Response.Buffer = true; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", $"attachment;filename={invoice.Id}_{invoice.Customer.LastName}.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(creator.CreatePdf(invoice)); //pdfgenerator doc return type Response.End(); } catch { } }
public async Task <IActionResult> GetCustomer([FromRoute] int id) { try { Customer customer = await _customersLogic.GetById(id); // only allow admins to access other user records /*var currentUserId = int.Parse(User.Identity.Name); * if (id != currentUserId && !User.IsInRole(Role.Admin)) * return Forbid();*/ if (customer == null) { return(NotFound()); } return(Ok(customer)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult GetById(int id) { return(Ok(_logic.GetById(id))); }