Ejemplo n.º 1
0
        public IActionResult OnPostSendSms([FromBody] Models.Received obj, string debname, string companyname, string debphone)
        {
            double amount        = obj.ReceivedAmount;
            bool   chequepayment = obj.ChequePaymet;
            string receivedate   = obj.ReceivedDate.ToShortDateString();


            var paymode = "";

            if (chequepayment == false)
            {
                paymode = "Cash";
            }
            else
            {
                paymode = "Cheque";
            }
            var DebtorGPhone = debphone;
            var DebtorName   = debname;
            var CompanyName  = companyname;

            SendSmsAsync(DebtorGPhone.Substring(DebtorGPhone.Length - 10), DebtorName, amount, paymode, receivedate, CompanyName);

            return(new JsonResult("SMS Sent to " + DebtorName + " on " + DebtorGPhone));
        }
Ejemplo n.º 2
0
        public IActionResult OnPostInsertReceived(int dgid, [FromBody] Models.Received obj)
        {
            obj.CompanyID     = (int)_session.GetInt32("Cid");
            obj.DebtorGroupID = _context.BillDetails.Where(a => a.BillDetailsID.Equals(obj.BillDetailsID)).Select(a => a.DebtorGroupID).FirstOrDefault();
            _context.Received.Add(obj);
            _context.SaveChanges();

            _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
            var amtout = _context.BillDetails.Where(a => a.BillDetailsID.Equals(obj.BillDetailsID)).FirstOrDefault().BillAmountOutstanding;
            // var amtout = _context.DebtorGroup.Where(a => a.DebtorGroupID.Equals(dgid)).FirstOrDefault().DebtorOutstanding;
            var billout = amtout - obj.ReceivedAmount;
            var billdet = new Models.BillDetails {
                BillDetailsID = obj.BillDetailsID, BillAmountOutstanding = billout
            };

            _context.BillDetails.Attach(billdet).Property(x => x.BillAmountOutstanding).IsModified = true;
            _context.SaveChanges();

            var dgout = _context.DebtorGroup.Where(a => a.DebtorGroupID.Equals(dgid)).FirstOrDefault().DebtorOutstanding;

            var debout = dgout - obj.ReceivedAmount;
            var dgdet  = new Models.DebtorGroup {
                DebtorGroupID = dgid, DebtorOutstanding = debout
            };

            _context.DebtorGroup.Attach(dgdet).Property(x => x.DebtorOutstanding).IsModified = true;
            _context.SaveChanges();

            return(new JsonResult("Successful!"));
        }