public HttpResponseMessage Create(HttpRequestMessage request, BillViewModel billViewModel) { try { Customer customer = new Customer(); customer.Address = billViewModel.Address; customer.Name = billViewModel.CustomerName; customer.Number = billViewModel.NumberPhone; customer = _daoClientScreen.AddCustomer(customer); SanPham sanPham = _daoClientScreen.GetProductById(billViewModel.IdProduct); DonHang donHang = new DonHang(); donHang.Id_product = billViewModel.IdProduct; donHang.Id_customer = customer.Id; donHang.Price = (decimal)sanPham.Price; donHang.Note = billViewModel.Descript; donHang.Insert_YMD = DateTime.Now; donHang.Update_YMD = DateTime.Now; donHang.Status = 0; _daoClientScreen.AddBill(donHang); return(request.CreateResponse(HttpStatusCode.OK)); } catch (Exception e) { return(request.CreateResponse(HttpStatusCode.NotImplemented)); } }
public int SendBillToAdmin(BillViewModel billViewModel) { DonHang donHang = new DonHang(); try { Customer customer = new Customer(); customer.Address = billViewModel.Address; customer.Name = billViewModel.CustomerName; customer.Number = billViewModel.NumberPhone; customer = _daoClientScreen.AddCustomer(customer); SanPham sanPham = _daoClientScreen.GetProductById(billViewModel.IdProduct); donHang.Id_product = billViewModel.IdProduct; donHang.Id_customer = customer.Id; donHang.Price = (decimal)sanPham.Price; donHang.Note = billViewModel.Descript; donHang.Insert_YMD = DateTime.Now; donHang.Update_YMD = DateTime.Now; donHang.Status = 0; _daoClientScreen.AddBill(donHang); Clients.Caller.SendStatus("true"); return(donHang.Id); } catch (Exception e) { Clients.Caller.SendStatus("false"); return(0); } }