public void TestCreateNewBill() { foreach (bool paid in new List <bool> { true, false }) { MockBillReaderWriter billWriter = new MockBillReaderWriter(); BillDetailViewModel billDetail = new BillDetailViewModel(billWriter, null, new NavigatorViewModel()); billDetail.Amount = 1; billDetail.BillName = "Test name"; billDetail.BillType = BillType.Food; billDetail.Description = "Test description"; billDetail.DueDate = new DateTime(1990, 1, 1); billDetail.IsAlreadyPaid = paid; Assert.IsTrue(billDetail.OnRecordButtonClick.CanExecute(null)); billDetail.OnRecordButtonClick.Execute(null); BillInfo actualBilLSaved = billWriter.BillSaved; Assert.AreEqual(actualBilLSaved.Amount, 1); Assert.AreEqual(actualBilLSaved.BillName, "Test name"); Assert.AreEqual(actualBilLSaved.Type, BillType.Food); Assert.AreEqual(actualBilLSaved.Description, "Test description"); Assert.AreEqual(actualBilLSaved.DueDate, new DateTime(1990, 1, 1)); Assert.AreEqual(actualBilLSaved.IsAlreadyPaid, paid); } }
public BillDetailViewModel AddDetail(BillDetailViewModel billDetailVm) { var billDetail = Mapper.Map <BillDetailViewModel, BillDetail>(billDetailVm); _orderDetailRepository.Insert(billDetail); return(billDetailVm); }
public BillDetailViewModel CreateDetail(BillDetailViewModel billDetailVm) { var billDetail = Mapper.Map <BillDetailViewModel, BillDetail>(billDetailVm); _orderDetailRepository.Add(billDetail); return(billDetailVm); }
private void btnSuaCTHD_Click(object sender, EventArgs e) { btnSuaCTHD.Text = btnSuaCTHD.Text.Equals("Sửa CTHD") ? "Cập nhật" : "Sửa CTHD"; if (btnSuaCTHD.Text.Equals("Sửa CTHD")) // An nut sửa lan 2 { //Code int id = int.Parse(gv_CTHoaDon.GetRowCellValue(gv_CTHoaDon.GetSelectedRows()[0], "Id").ToString()); BillDetailViewModel b = _billDetailList.FirstOrDefault(bdt => bdt.Id == id); b.ProductId = int.Parse(cbMaSP.SelectedValue.ToString()); b.SizeId = int.Parse(cbSize.SelectedValue.ToString()); b.Price = decimal.Parse(txtDonGia.Text.Trim()); b.Quantity = int.Parse(txtSoLuong.Text.Trim()); MessageBox.Show("Cập nhật thành công !"); //End Code loadGvFormBillDetailList(); reStart_BillDetail(); datagv_CTHoaDon.Enabled = true; setBtnBackCTHD_False(); setEdit_False(); } else //Vua nhan nut sửa { setEdit_True(); saveStament_BillDetail(); setBtnBackCTHD_True(); btnSuaCTHD.Enabled = true; btnXoaCTHD.Enabled = btnThemCTHD.Enabled = false; datagv_CTHoaDon.Enabled = false; } update_BillDetail_Edit(); }
public async Task<BillViewModel> Create(BillViewModel billVm) { try { //var order = Mapper.Map<BillViewModel, Bill>(billVm); var order = new BillViewModel().Map(billVm); // var orderDetails = Mapper.Map<List<BillDetailViewModel>, List<BillDetail>>(billVm.BillDetails); var orderDetails = new BillDetailViewModel().Map(billVm.BillDetails.AsParallel().AsOrdered().WithDegreeOfParallelism(3)).ToList(); foreach (var detail in orderDetails) { var product =await _productRepository.FindById(detail.ProductId); detail.Price = product.Price; } order.BillDetails = orderDetails; var billEntity = await _orderRepository.AddAsync(order); return new BillViewModel().Map(billEntity); } catch (Exception e) { Console.WriteLine(e); throw; } }
public BillDetailViewModel CreateDetail(BillDetailViewModel billDetailVm) { var billDetail = billDetailVm.AddModel(); _orderDetailRepository.Add(billDetail); return(billDetailVm); }
public NewBillItemPage() { InitializeComponent(); BindingContext = new BillDetailViewModel(); db = new BillManagerDB(); Setup(); }
public async Task <BillDetailViewModel> CreateDetail(BillDetailViewModel billDetailVm) { var billDetail = new BillDetailViewModel().Map(billDetailVm); await _orderDetailRepository.Add(billDetail); return(billDetailVm); }
public ActionResult BillDetails(int ChallanId, string BillId) { BillDetailViewModel model = new BillDetailViewModel(); List <BillDetails> lst = new List <BillDetails>(); lst = challanDAL.ReadChallanDetailsByChallanId(ChallanId, BillId); model.lstDetails = new List <BillDetailViewModel>(); model.CustomerName = lst[0].CustomerName; model.CustomerAddress = lst[0].CustomerAddress; model.ChallanId = lst[0].ChallanId; model.BillId = lst[0].BillId; model.lstDetails = lst.ConvertAll(x => new BillDetailViewModel { CategoryId = x.CategoryId, CategoryName = x.CategoryName, CategoryQuantity = x.CategoryQuantity, CustomerName = x.CustomerName, CustomerAddress = x.CustomerAddress, // SubCategoryId=x.SubCategoryId, //CurrentStock=(decimal)(x.CurrentStock), lstSubCategory = subcategoryDAL.ReadSubCategoryByCategory(x.CategoryId) }); return(View(model)); }
public ActionResult AddSubCategoryToCategory(BillDetailViewModel model) { List <BillDetails> details = new List <BillDetails>(); for (int i = 0; i < model.lstDetails.Count; i++) { for (int j = 0; j < model.lstDetails[i].lstSubCategory.Count; j++) { if (model.lstDetails[i].lstSubCategory[j].Quantity == 0 || model.lstDetails[i].lstSubCategory[j].Quantity == null) { } else { BillDetails billdetails = new BillDetails(); billdetails.ChallanId = model.ChallanId; billdetails.BillId = model.BillId; billdetails.CategoryId = model.lstDetails[i].CategoryId; billdetails.SubCategoryId = model.lstDetails[i].lstSubCategory[j].SubCategoryId; billdetails.Quantity = Convert.ToDecimal(model.lstDetails[i].lstSubCategory[j].Quantity); details.Add(billdetails); } } } challanDAL.AddSubCategory(details); TempData["SuccessMsg"] = "Bill Created Successfully"; return(RedirectToAction("Index")); }
public BillDetailViewModel CreateDetail(BillDetailViewModel billDetailVm) { var billDetail = Mapper.Map <BillDetailViewModel, BillDetail>(billDetailVm); _unitOfWork.BillDetailRepository.Add(billDetail); _unitOfWork.Commit(); return(billDetailVm); }
public async Task <BillDetailViewModel> CreateDetailAsync(BillDetailViewModel billDetailViewModel) { var billDetail = _mapper.Map <BillDetail>(billDetailViewModel); _billDetailRepository.Add(billDetail); await _unitOfWork.CommitAsync(); return(billDetailViewModel); }
public static void UpdateBillDetail(this BillDetail billDetail, BillDetailViewModel billDetailVm) { billDetail.BillId = billDetailVm.BillId; billDetail.ProductId = billDetailVm.ProductId; billDetail.Quantity = billDetailVm.Quantity; billDetail.Price = billDetailVm.Price; billDetail.ColorId = billDetailVm.ColorId; billDetail.SizeId = billDetailVm.SizeId; }
public void TestBillDetailLoadWillResetNavigatorBillIdSelected() { NavigatorViewModel nav = new NavigatorViewModel(); nav.BillIdSelected = 1; BillDetailViewModel _ = new BillDetailViewModel(new MockBillReaderWriter(), null, nav); Assert.AreEqual(nav.BillIdSelected, 0); }
public BillDetail(BillDetailViewModel billDetailVm) { BillId = billDetailVm.BillId; ProductId = billDetailVm.ProductId; Quantity = billDetailVm.Quantity; Price = billDetailVm.Price; OriginalPrice = billDetailVm.OriginalPrice; ColorId = billDetailVm.ColorId; SizeId = billDetailVm.SizeId; }
public frmBill_BillDetailt(IBillService billService, IProductService productService) { InitializeComponent(); _billService = billService; _productService = productService; _bill = new BillViewModel(); _product = new ProductViewModel(); _billDetail = new BillDetailViewModel(); _billDetailList = new List <BillDetailViewModel>(); }
private static BillDetailViewModel GetBillDetailViewModel() { BillDetailViewModel bdvm = new BillDetailViewModel( new SqliteDbBillReaderWriter(Constants.CONN_STRING), new FileToByteStreamUiService(), _navigator); bdvm.PopUpService = new MessageBoxService(); return(bdvm); }
public ActionResult Details(long?id) { var bill = billService.GetById(id ?? 0) ?? new Bill(); var viewModel = new BillDetailViewModel { Bill = bill, Currency = currencyService.GetById(bill.CurrencyId ?? 0) ?? new Currency(), Vendor = vendorService.GetById(bill.VendorId ?? 0) ?? new Vendor(), Branch = branchService.GetById(LogedInUser.BranchId ?? 0) }; return(View(viewModel)); }
public void TestBillDetailViewWillAlwaysGetAllBillTypes() { Mock <IBillReaderWriter> mockWriter = new Mock <IBillReaderWriter>(); BillDetailViewModel vm = new BillDetailViewModel(mockWriter.Object, null, new NavigatorViewModel()); Assert.AreEqual(vm.AllBillTypes.Count, 4); foreach (BillType type in new List <BillType> { BillType.Food, BillType.MiscSpending, BillType.Unknown, BillType.Utility }) { Assert.IsTrue(vm.AllBillTypes.Contains(type)); } }
public GenericResult CreateDetail(BillDetailViewModel billDetailViewModel) { try { var billDetail = _mapper.Map <BillDetailViewModel, BillDetail>(billDetailViewModel); _orderDetailRepository.Add(billDetail); return(new GenericResult(true, "Add Successful", "Successful")); } catch (Exception) { return(new GenericResult(false, "Add Failed", "Error")); } }
public IActionResult GetProductForClient([FromBody] BillDetailViewModel model) { try { var detailBills = _billDetailService.GetCartForAuthUser(model.AuthUserId, "Product,Bill,AuthUser"); var result = Mapper.Map <IEnumerable <BillDetailForClientViewModel> >(detailBills); return(Ok(result)); } catch (Exception e) { return(BadRequest(e.Message)); } }
private void gv_CTHoaDon_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { int rowIndex = e.RowHandle; int id = int.Parse(gv_CTHoaDon.GetRowCellValue(rowIndex, "Id").ToString()); BillDetailViewModel bd = _billDetailList.FirstOrDefault(b => b.Id == id); bd.ProductId = int.Parse(gv_CTHoaDon.GetRowCellValue(rowIndex, "ProductId").ToString()); bd.SizeId = int.Parse(gv_CTHoaDon.GetRowCellValue(rowIndex, "SizeId").ToString()); bd.Price = decimal.Parse(gv_CTHoaDon.GetRowCellValue(rowIndex, "Price").ToString()); bd.Quantity = int.Parse(gv_CTHoaDon.GetRowCellValue(rowIndex, "Quantity").ToString()); gv_HoaDon.SelectRow(rowIndex); loadGvFormBillDetailList(); }
public void TestBillDetailSwitchBackToBillSearchOnSaveSuccessOrCancel() { NavigatorViewModel nav = new NavigatorViewModel(); nav.ViewNameToDisplay = Constants.BillDetailView; BillDetailViewModel bd = new BillDetailViewModel(new MockBillReaderWriter(), null, nav); bd.OnRecordButtonClick.Execute(null); Assert.AreEqual(nav.ViewNameToDisplay, Constants.BillSearchView); nav.ViewNameToDisplay = Constants.BillDetailView; bd.OnCancel.Execute(null); Assert.AreEqual(nav.ViewNameToDisplay, Constants.BillSearchView); }
private void btnXoaCTHD_Click(object sender, EventArgs e) { string id = gv_CTHoaDon.GetRowCellValue(gv_CTHoaDon.GetSelectedRows()[0], "Id").ToString(); if (FormHelper.showRemoveDialog("chi tiết hoá đơn có mã " + id) == DialogResult.No) { return; } BillDetailViewModel bd = _billDetailList.FirstOrDefault(b => b.Id == int.Parse(id)); _billDetailList.Remove(bd); MessageBox.Show("Xoá thành công !"); loadGvFormBillDetailList(); reStart_BillDetail(); }
public ActionResult EditDetail(BillDetailViewModel obj) { obj.IsEdit = true; obj.ListProducts = ListProducts(); obj.ListColors = ListColors(); obj.ListSizes = ListSizes(); var content = _viewRenderService.RenderToStringAsync("Bill/_AddEditDetailModal", obj); return(Json(new JsonResponse { Success = true, Message = Constants.GetDataSuccess, StatusCode = Utilities.Constants.StatusCode.GetDataSuccess, Data = content.Result, })); }
public void TestCanParseFileAndSaveItsContent() { FilePickerMock filePicker = new FilePickerMock(); BillDetailViewModel billDetail = new BillDetailViewModel( new MockBillReaderWriter(), filePicker, new NavigatorViewModel()); byte[] expectedAttachment = new byte[] { 1, 5, 3, 2 }; filePicker.Output = expectedAttachment; billDetail.ImportBillAttachment.Execute(null); Assert.AreEqual(billDetail.Attachement.Length, expectedAttachment.Length); for (int i = 0; i < expectedAttachment.Length; i++) { Assert.AreEqual(billDetail.Attachement[i], expectedAttachment[i]); } }
public void TestBillDetailStaysSameOnSaveFailure() { MockBillReaderWriter readerWriter = new MockBillReaderWriter( () => new List <BillInfo>(), (BillInfo _, out string err) => { err = ""; return(false); }); NavigatorViewModel nav = new NavigatorViewModel(); nav.ViewNameToDisplay = Constants.BillDetailView; BillDetailViewModel db = new BillDetailViewModel(readerWriter, null, nav); db.OnRecordButtonClick.Execute(null); Assert.AreEqual(nav.ViewNameToDisplay, Constants.BillDetailView); }
public async Task <IActionResult> Add([FromBody] BillDetailViewModel model) { try { model.Id = new Guid(); //lay price cua product var product = await _productService.FindByIdAsync(model.ProductId); model.PriceTotal = model.Amount * product.Price; await _billDetailService.CreateAsync(model); return(Ok()); } catch (Exception e) { return(BadRequest(e.Message)); } }
private void btnThemCTHD_Click(object sender, EventArgs e) { btnThemCTHD.Text = btnThemCTHD.Text.Equals("Them CTHD") ? "Lưu" : "Them CTHD"; if (btnThemCTHD.Text.Equals("Them CTHD")) // An nut them lan 2 { if (!isValid_BillDetail()) { MessageBox.Show("Ban phai nhap day du thông tin !"); btnThemCTHD.Text = "Lưu"; return; } BillDetailViewModel bdt = new BillDetailViewModel() { Id = _billDetailList.Count, BillId = (_billService.GetAllBill().Max(b => b.Id) + 1), ProductId = int.Parse(cbMaSP.SelectedValue.ToString()), SizeId = int.Parse(cbSize.SelectedValue.ToString()), Price = decimal.Parse(txtDonGia.Text.Trim()), Quantity = int.Parse(txtSoLuong.Text.Trim()) }; if (_billDetailList.Any(b => b.ProductId == bdt.ProductId && b.SizeId == bdt.SizeId)) { MessageBox.Show("Đã tồn tại Chi tiết háo đơn này trong bill !"); btnThemCTHD.Text = "Lưu"; return; } _billDetailList.Add(bdt); loadGvFormBillDetailList(); update_BillDetail_Edit(); datagv_CTHoaDon.Enabled = btnInHD.Enabled = true; setBtnBackCTHD_False(); setEdit_False(); } else //Vua nhan nut them { setEdit_True(); saveStament_BillDetail(); setBtnBackCTHD_True(); reStart_BillDetail(); datagv_CTHoaDon.Enabled = false; } }
public void TestBillDetailLoadWillSetBillInfo() { MockBillReaderWriter readerWriter = new MockBillReaderWriter(); IList <BillInfo> allBills = readerWriter.GetAllBills(); NavigatorViewModel nav = new NavigatorViewModel(); nav.BillIdSelected = 2; BillDetailViewModel billDetail = new BillDetailViewModel(readerWriter, null, nav); BillInfo billInBillDetailModel = new BillInfo() { Amount = billDetail.Amount, BillName = billDetail.BillName, Description = billDetail.Description, DueDate = billDetail.DueDate, Type = billDetail.BillType, IsAlreadyPaid = billDetail.IsAlreadyPaid, Attachement = billDetail.Attachement }; Assert.IsTrue(billInBillDetailModel.SameData(allBills[1])); }