コード例 #1
0
 public void ForceUpdate(SupplierInvoice si, string username)
 {
     SupplierInvoice exist = _repository.GetById(si.id, si.BranchId);
     if (exist == null)
         throw new Exception("Data tidak ditemukan.");
     SupplierInvoice siUpdated = new SupplierInvoice()
     {
         id = exist.id,
         ProductId = exist.ProductId,
         BranchId = exist.BranchId,
         SupplierInvoiceNo = exist.SupplierInvoiceNo,
         TransactionDate = exist.TransactionDate,
         HargaBeli = si.HargaBeli,
         Merk = si.Merk,
         NoBpkb = si.NoBpkb,
         NoMesin = si.NoMesin,
         NoPolisi = si.NoPolisi,
         NoRangka = si.NoRangka,
         SupplierBillingAddress = si.SupplierBillingAddress,
         SupplierInvoiceDate = si.SupplierInvoiceDate,
         SupplierName = si.SupplierName,
         Tahun = si.Tahun,
         Type = si.Type,
         Warna = si.Warna,
         Note = si.Note,
         NoTelp = si.NoTelp,
         Charge = si.Charge
     };
     ForceUpdateProduct(siUpdated, username);
     ReportingRepository.Update<SupplierInvoice>(siUpdated, new { Id = si.id });
     PublishSupplierInvoiceChanged(siUpdated, username);
     PublishSupplierInvoicePriceChanged(siUpdated, exist, username);
 }
コード例 #2
0
 public void Create(SupplierInvoice si, string username)
 {
     si.TransactionDate = DateTime.Now;
     si.SupplierInvoiceDate = si.SupplierInvoiceDate.UtcDate();
     Product productCreated = CreateProduct(si, username);
     si.SupplierInvoiceNo = _autoNumberGenerator.GenerateSINumber(si.TransactionDate, si.BranchId);
     try
     {
         ReportingRepository.Save<SupplierInvoice>(si);
         PublishSupplierInvoiceCreated(si, username);
     }
     catch
     {
         ProductService.Delete(productCreated);
     }
 }
コード例 #3
0
ファイル: PurchaseController.cs プロジェクト: AsliMotor/AMQ
 public JsonResult CreatePurchase(SupplierInvoice si)
 {
     try
     {
         CompanyProfile cp = new CompanyProfile(this.HttpContext);
         si.BranchId = cp.BranchId;
         si.id = Guid.NewGuid();
         si.ProductId = Guid.NewGuid();
         SupplierInvoiceService.Create(si, cp.UserName);
         return Json(new { error = false, data = si }, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         return Json(new { error = true, message = ex.Message }, JsonRequestBehavior.AllowGet);
     }
 }
コード例 #4
0
 private void UpdateProduct(SupplierInvoice si, string username)
 {
     Product product = new Product()
     {
         id = si.ProductId,
         BranchId = si.BranchId,
         HargaBeli = si.HargaBeli,
         Merk = si.Merk,
         NoBpkb = si.NoBpkb,
         NoMesin = si.NoMesin,
         NoPolisi = si.NoPolisi,
         NoRangka = si.NoRangka,
         Status = StatusProduct.AKTIF,
         Tahun = si.Tahun,
         Type = si.Type,
         Warna = si.Warna
     };
     ProductService.Update(product, username);
 }
コード例 #5
0
 private void PublishSupplierInvoicePriceChanged(SupplierInvoice siUpdated, SupplierInvoice exist, string username)
 {
     if (_bus != null)
     {
         if (siUpdated.HargaBeli != exist.HargaBeli || siUpdated.Charge != exist.Charge)
             _bus.Publish(new PriceSupplierInvoiceChanged
             {
                 Payload = siUpdated,
                 UserName = username,
                 BeforeCharge = exist.Charge,
                 BeforeHargaBeli = exist.HargaBeli
             });
     }
 }
コード例 #6
0
 private void PublishSupplierInvoiceCreated(SupplierInvoice si, string username)
 {
     if (_bus != null)
     {
         _bus.Publish(new SupplierInvoiceCreated { Payload = si, UserName = username });
     }
 }
コード例 #7
0
ファイル: PurchaseController.cs プロジェクト: AsliMotor/AMQ
        public JsonResult Purchase(SupplierInvoice si)
        {
            try
            {
                CompanyProfile cp = new CompanyProfile(this.HttpContext);

                if (this.HttpContext.User.IsInRole(RoleName.OWNER))
                {
                    SupplierInvoiceService.ForceUpdate(si, cp.UserName);
                }
                else
                {
                    SupplierInvoiceService.Update(si, cp.UserName);
                }
                return Json(new { error = false, data = si }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new { error = true, message = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }