示例#1
0
        public IActionResult TesEmailInvoice()
        {
            PurchaseOutputModel OutPutData = new PurchaseOutputModel();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseAPI + "MediaBuyer/");
                var responseTask = client.PostAsync("TesEmailInvoice", null);
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var content = result.Content.ReadAsStringAsync();
                    PurchaseResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <PurchaseResponseModel>(content.Result);
                    OutPutData = resutl.data;
                }
                else                 //web api sent error response
                {
                    //log response status here..
                    ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin.");
                }
            }
            return(Json(OutPutData));
        }
示例#2
0
        public IActionResult ProcessToPurchase()
        {
            PurchaseOutputModel OutPutData = new PurchaseOutputModel();
            PurchaseInputModel  filter     = new PurchaseInputModel();

            filter.UserID     = Guid.Parse(HttpContext.Session.GetString(SessionKeyID));
            filter.SubTotal   = double.Parse("");
            filter.Diskon     = double.Parse("");
            filter.GrandTotal = double.Parse("");
            //filter.BookID = [""];
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseAPI + "MediaBuyer/");
                var responseTask = client.PostAsJsonAsync <PurchaseInputModel>("GetRoleDropDown", filter);
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var content = result.Content.ReadAsStringAsync();
                    PurchaseResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <PurchaseResponseModel>(content.Result);
                    OutPutData = resutl.data;
                }
                else                 //web api sent error response
                {
                    //log response status here..
                    ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin.");
                }
            }
            return(Json(OutPutData));
        }
        public ActionResult <PurchaseResponseModel> TesEmailInvoice()
        {
            PurchaseResponseModel res = new PurchaseResponseModel();

            try
            {
                PurchaseOutputModel temp = new PurchaseOutputModel();

                ReportBL invoice = new ReportBL(DbContext);

                var body = invoice.BuildInvoice(temp);

                MailMessage message = new MailMessage();
                message.To.Add("*****@*****.**");
                message.Body       = body;
                message.Subject    = "Pembelian 7061BTJW Telah Selesai";
                message.From       = new MailAddress(AppSettings.EmailConfig.FromAddress);
                message.IsBodyHtml = true;

                PdfConvertEngine pdfEngine = new PdfConvertEngine();

                var pdfPath = pdfEngine.ConvertHTMLToPDF(body, AppSettings.PDFPath, "INV_01_123");

                Attachment dataPDF = new Attachment(pdfPath);

                message.Attachments.Add(dataPDF);

                EmailSenderEngine emailEngine = new EmailSenderEngine();
                string            configJSON  = JsonConvert.SerializeObject(AppSettings.EmailConfig);

                emailEngine.SendEmail(message, configJSON);
                dataPDF.Dispose();


                return(res);
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;

                return(res);
            }
        }
示例#4
0
        public PurchaseOutputModel Process(PurchaseInputModel data)
        {
            PurchaseRepository repo = new PurchaseRepository(db);

            Payment temp = new Payment();

            DateTime today = DateTime.Now;

            temp.Diskon         = data.Diskon;
            temp.InvoiceNo      = GenerateInvoice();
            temp.UserID         = data.UserID;
            temp.TotalPrice     = data.GrandTotal;
            temp.SubTotalPrice  = data.SubTotal;
            temp.CreateByUserID = data.UserID;
            temp.CreateDate     = today;
            temp.TotalPaid      = data.UangMuka;
            temp.PPNProsen      = data.PPNProsen;
            temp.isLunas        = data.GrandTotal - data.UangMuka == 0 ? true : false;

            if (data.BookID.Count() > 0)
            {
                foreach (var x in data.BookID)
                {
                    Guid bookID = new Guid();
                    bookID      = Guid.Parse(x);
                    temp.BookID = bookID;
                    //keterangan user bayar full payment atau DP

                    var paymentTypeQuery = (from p in db.Payment
                                            join m in db.MidTransLog on p.ID equals m.PaymentID
                                            where p.BookID == bookID && m.MidTransStatus != 0
                                            select new
                    {
                        m
                    });

                    var countPaymentType = paymentTypeQuery.Count();

                    temp.PaymentType = countPaymentType == 0 && data.GrandTotal - data.UangMuka == 0 ? (int)TransactionTypeEnum.FullPayment :
                                       countPaymentType < 1 && data.GrandTotal - data.UangMuka != 0 ? (int)TransactionTypeEnum.DP : (int)TransactionTypeEnum.FullPayment;
                }
            }



            var res = repo.Insert(temp);

            PurchaseOutputModel output = new PurchaseOutputModel();

            if (res.ID != Guid.Empty)
            {
                output.IDTransaction = res.ID;
                output.InvoiceNo     = temp.InvoiceNo;

                List <Guid> listBookID = new List <Guid>();

                foreach (var x in data.BookID)
                {
                    listBookID.Add(Guid.Parse(x));
                }

                BookRepository bookRepo = new BookRepository(db);

                bookRepo.UpdatePurchase(listBookID, res.ID);
            }

            return(output);
        }
示例#5
0
        public ActionResult ProceedPayment(string bookID, double hargaAmt, double discAmt, double totalAmt, double payAmt)
        {
            if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "")
            {
                MidTransTransactionResponseModel OutPutData = null;
                MidTransChargeInputModel         filter     = new MidTransChargeInputModel();
                PurchaseOutputModel OutPutPurch             = null;
                PurchaseInputModel  inputPurch = new PurchaseInputModel();
                inputPurch.SubTotal   = hargaAmt;
                inputPurch.Diskon     = discAmt;
                inputPurch.GrandTotal = totalAmt;
                inputPurch.UangMuka   = payAmt;
                inputPurch.UserID     = Guid.Parse(HttpContext.Session.GetString(SessionKeyID));
                inputPurch.BookID     = new string[1];
                inputPurch.BookID[0]  = bookID;
                using (var clientPurch = new HttpClient())
                {
                    clientPurch.BaseAddress = new Uri(BaseAPI + "MediaBuyer/");
                    var responseTaskPurch = clientPurch.PostAsJsonAsync <PurchaseInputModel>("ProcessToPurchase", inputPurch);
                    responseTaskPurch.Wait();

                    var resultPurch = responseTaskPurch.Result;
                    if (resultPurch.IsSuccessStatusCode)
                    {
                        var contentPurch = resultPurch.Content.ReadAsStringAsync();
                        PurchaseResponseModel resutlPurch = Newtonsoft.Json.JsonConvert.DeserializeObject <PurchaseResponseModel>(contentPurch.Result);
                        OutPutPurch = resutlPurch.data;
                        if (OutPutPurch != null)
                        {
                            filter.customer_details = new CustomerDetails();
                            filter.customer_details.billing_address  = new BillingAddress();
                            filter.customer_details.shipping_address = new ShippingAddress();
                            filter.transaction_details              = new TransactionDetails();
                            filter.transaction_details.currency     = "IDR";
                            filter.transaction_details.order_id     = OutPutPurch.InvoiceNo;
                            filter.transaction_details.gross_amount = payAmt;
                            filter.user_id = HttpContext.Session.GetString(SessionKeyID);
                            using (var client = new HttpClient())
                            {
                                client.BaseAddress = new Uri(BaseAPI.Replace("api/", ""));
                                var responseTask = client.PostAsJsonAsync <MidTransChargeInputModel>("charge", filter);
                                responseTask.Wait();

                                var result = responseTask.Result;
                                if (result.IsSuccessStatusCode)
                                {
                                    var content = result.Content.ReadAsStringAsync();
                                    MidTransTransactionResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <MidTransTransactionResponseModel>(content.Result);
                                    OutPutData = resutl;
                                }
                                else                                 //web api sent error response
                                {
                                    //log response status here..
                                    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                                }
                            }
                        }
                    }
                    else                     //web api sent error response
                    {
                        //log response status here..
                        ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                    }
                }

                return(Json(OutPutData));
            }
            else
            {
                TempData["CustomError"] = "Please login before using the web.";
                if (HttpContext.Session.GetString(Loginfrom) == "ADM/SPV")
                {
                    return(RedirectToAction("AdminLogon", "Login"));
                }
                else if (HttpContext.Session.GetString(Loginfrom) == "MDO")
                {
                    return(RedirectToAction("OwnerLogon", "Login"));
                }
                else
                {
                    return(RedirectToAction("BuyerLogon", "Login"));
                }
                //return RedirectToAction("Logon", "Login");
            }
        }
示例#6
0
        public string BuildInvoice(PurchaseOutputModel data)
        {
            string headLiner      = "Billboard Indo";
            string address        = "Jl. Pluto Bima Sakti <br/>  No 123  <br/>  Galaxy Alam Semesta";
            string greetingMsg    = "Hai Enggar,";
            string thxMessage     = "Pembelianmu Telah Selesai";
            string mediaOwnerName = "Warna Warni";
            string noBillboard    = "7061BTJW";
            string priceItem      = "Rp 30.000.000";
            string subThxMessage  = "Pembelian <b>" + noBillboard + "</b> telah selesai. Dana pembelianmu akan diteruskan ke Media Owner";

            string itemHtml = "";

            itemHtml += "<div style='padding-left: 10px; padding-bottom: 10px; padding-top: 10px;'>";
            itemHtml += "<div style='width: 300px; float: left;'>" + noBillboard + "</div>";
            itemHtml += "<div style='text-align: right; padding-right: 10px;'>" + priceItem + "</div>";

            string total = "";

            total = "Rp 30.000.000";

            string content = "";

            content += "<html>";
            content += "<head></head>";
            content += "<body style='font-family:Trebuchet MS, Lucida Sans Unicode, Lucida Grande, Lucida Sans, Arial, sans-serif; padding: 10px;'>";
            content += "<div style='width: 450px;'>";
            content += "<div style='background-color:#0E62AC;'>";
            content += "<h3 style='padding: 10px; color: #ffffff;'>" + headLiner + "</h3>";
            content += "</div>";
            content += "<div style='padding: 10px;'>";
            content += "<div id='content'>";
            content += "<p>" + greetingMsg + "</p>";
            content += "<h2>" + thxMessage + "<h2/>";
            content += "<p style='color:#616161;'>" + subThxMessage + "</p>";
            content += "<div>";
            content += "<div style='width:200px; float: left;'>Media Owner</div>";
            content += "<div style='text-align: left; padding-right: 10px;'>: " + mediaOwnerName + "</div>";
            content += "</div><br/>";
            content += "<div style='background-color:#e0e0e0; padding-left: 10px; padding-bottom: 10px; padding-top: 10px; border-radius: 5px ;'>";
            content += "<div>";
            content += "<div style='width: 300px; float: left;'><b>Invoice No</b></div>";
            content += "<div style='text-align: right; padding-right: 10px;'><b>INV/20200121/012</b></div>";
            content += "</div>";
            content += "</div>";
            content += itemHtml;
            content += "<div style='padding-left: 10px; padding-bottom: 10px; padding-top: 10px; border-top-color: #e0e0e0 ; border-bottom-color: #e0e0e0; border-style: solid; border-right-style:hidden; border-left-style:hidden;'>";
            content += "<div style='width: 300px; float: left; '><b>Total</b>";
            content += "</div>";
            content += "<div style='text-align: right; padding-right: 10px;'><b>" + total + "</b>";
            content += "</div>";
            content += "</div>";
            content += "<br/><br/><br/>";
            content += "</div>";
            content += "<div style='background-color:#0E62AC; color: #ffffff; padding: 10px; text-align: right;'>";
            content += "<b>" + headLiner + "</b><br/>";
            content += address + "</div>";
            content += "</body></html>";

            return(content);
        }