Example #1
0
        public ActionResult PaidBillEdit(tblBill bill)
        {
            if (ModelState.IsValid)
            {
                tblPaidBillModel model = new tblPaidBillModel();

                model.Bid            = bill.Bid;
                model.PaymentAmount1 = bill.PaymentAmount1;
                model.PaymentAmount2 = bill.PaymentAmount2;
                model.PaymentDate1   = bill.PaymentDate1;
                model.PaymentDate2   = bill.PaymentDate2;
                model.Monthcharge    = bill.Monthcharge;
                model.Balance        = bill.Balance;


                _db.Entry(bill).State = EntityState.Modified;
                _db.SaveChanges();

                var result = _objReg.PaidBill(model);

                return(RedirectToAction("Dashboard", "Admin"));
            }

            return(View(bill));
        }
        public async Task <ProjectResult> ApprovalRequest(int id)
        {
            string OperatorCode = GenerateRandomChar() + Convert.ToString(GenerateRandomNo());

            tblAdminRegistration _objAdmin = _db.tblAdminRegistrations.Find(id);

            try
            {
                var result = _db.tblAdminRegistrations.Where(psd => psd.OperatorCode == OperatorCode).ToList();

                if (result.Count == 0)
                {
                    _objAdmin.SkyStatus        = 1;
                    _objAdmin.OperatorCode     = OperatorCode;
                    _db.Entry(_objAdmin).State = EntityState.Modified;
                    _db.SaveChanges();
                }
                else
                {
                    OperatorCode               = GenerateRandomChar() + Convert.ToString(GenerateRandomNo());
                    _objAdmin.SkyStatus        = 1;
                    _objAdmin.OperatorCode     = OperatorCode;
                    _db.Entry(_objAdmin).State = EntityState.Modified;
                    _db.SaveChanges();
                }


                return(new ProjectResult {
                    Message = "Success", Status = 1, Response = "Success"
                });
            }
            catch (Exception exp)
            {
                return(new ProjectResult {
                    Message = exp.ToString(), Status = 0, Response = null
                });
            }
        }
        public async Task <ProjectResult> PaidBill(tblPaidBillModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // var result = _db.tblBills.Where(psd=>psd.CustId==model.CustId).FirstOrDefault();

                    using (CableApiAndroidEntity _db = new CableApiAndroidEntity())
                    {
                        tblBill _objBill = (from psd in _db.tblBills.Where(psd => psd.Bid == model.Bid) select psd).FirstOrDefault();
                        tblCustomerRegistration _objCust = (from psd in _db.tblCustomerRegistrations.Where(psd => psd.CustId == _objBill.CustId) select psd).FirstOrDefault();

                        if (model.PaymentAmount2 != 0 && model.PaymentDate2 != "")
                        {
                            //_objBill.PaymentAmount1 = model.PaymentAmount1;
                            //_objBill.PaymentDate1 = model.PaymentDate1;
                            _objBill.PaymentAmount2 = model.PaymentAmount2;
                            _objBill.PaymentDate2   = model.PaymentDate2;
                            _objBill.Balance        = model.Balance;
                            _objBill.Bid            = model.Bid;
                        }
                        else
                        {
                            _objBill.PaymentAmount1 = model.PaymentAmount1;
                            _objBill.PaymentDate1   = model.PaymentDate1;
                            _objBill.PaymentAmount2 = 0;
                            _objBill.PaymentDate2   = "";
                            _objBill.Balance        = model.Balance;
                            _objBill.Bid            = model.Bid;
                        }



                        if (model.PaymentAmount1 != 0 && model.PaymentAmount2 == 0)
                        {
                            //_objBill.Balance = (model.Monthcharge-model.PaymentAmount1);
                            _objCust.OldBal = model.Balance;
                        }
                        else
                        {
                            //_objBill.Balance = (model.Monthcharge - (model.PaymentAmount2 + model.PaymentAmount1));
                            _objCust.OldBal = model.Balance;
                        }

                        _db.Entry(_objBill).State = System.Data.Entity.EntityState.Modified;
                        _db.SaveChanges();

                        _db.Entry(_objCust).State = System.Data.Entity.EntityState.Modified;
                        _db.SaveChanges();

                        return(new ProjectResult {
                            Message = "Success", Status = 1, Response = _objBill
                        });
                    }
                }
                else
                {
                    return(new ProjectResult {
                        Message = "Failed", Status = 0, Response = null
                    });
                }
            }
            catch (Exception exp)
            {
                return(new ProjectResult {
                    Message = exp.ToString(), Status = 0, Response = null
                });
            }
        }
        public async Task <ProjectResult> AdminRegistration(tblAdminRegistration model)
        {
            try
            {
                var result1 = _db.tblAdminRegistrations.Where(a => a.UserId == model.UserId && a.Password == model.Password && a.IMEINo == model.IMEINo).ToList();
                if (result1.Count != 0)
                {
                    return(new ProjectResult {
                        Message = "User Already Exist", Status = 2, Response = result1
                    });
                }
                else
                {
                    model.SkyStatus = 0;
                    var result = _db.tblAdminRegistrations.Max(psd => psd.RegId);
                    if (result == null)
                    {
                        result = 0;
                    }
                    model.RegId = (result.Value) + 1;

                    tblAdminRegistration _objAdmin = new tblAdminRegistration();

                    if (ModelState.IsValid)
                    {
                        _objAdmin.RegId     = model.RegId;
                        _objAdmin.Name      = model.Name;
                        _objAdmin.Address   = model.Address;
                        _objAdmin.City      = model.City;
                        _objAdmin.Email     = model.Email;
                        _objAdmin.MobileNo  = model.MobileNo;
                        _objAdmin.UserId    = model.UserId;
                        _objAdmin.Password  = model.Password;
                        _objAdmin.Pin       = model.Pin;
                        _objAdmin.NoOfAgent = model.NoOfAgent;
                        //_objAdmin.RegDate = model.RegDate;
                        _objAdmin.RegDate      = System.DateTime.Now.Date;
                        _objAdmin.SkyStatus    = model.SkyStatus;
                        _objAdmin.IMEINo       = model.IMEINo;
                        _objAdmin.OperatorCode = model.OperatorCode;

                        _db.tblAdminRegistrations.Add(_objAdmin);
                        _db.SaveChanges();


                        return(new ProjectResult {
                            Message = "Success", Status = 1, Response = _objAdmin
                        });
                    }
                    else
                    {
                        return(new ProjectResult {
                            Message = "No data found", Status = 0, Response = null
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                return(new ProjectResult {
                    Message = ex.ToString(), Status = 0, Response = null
                });
            }
        }