Пример #1
0
        public ActionResult BulkUpdate(int feetypeid, DateTime duedate, long?[] id, long[] studentid, string[] amount, FeePaymentStatus[] status)
        {
            var feetype = db.fees_types.SingleOrDefault(x => x.id == feetypeid);

            if (feetype == null)
            {
                return(Json("Unable to find Fee Type".ToJsonFail()));
            }

            for (int i = 0; i < studentid.Length; i++)
            {
                var feeid     = id[i];
                var userid    = studentid[i];
                var feetotal  = amount[i];
                var feestatus = status[i];

                if (feeid.HasValue)
                {
                    var fee = db.fees.Single(x => x.id == feeid.Value);
                    if (feestatus == FeePaymentStatus.UNKNOWN || string.IsNullOrEmpty(feetotal))
                    {
                        db.fees.DeleteOnSubmit(fee);
                    }
                    else
                    {
                        fee.name   = feetype.name;
                        fee.amount = decimal.Parse(feetotal,
                                                   NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands);
                        fee.status  = feestatus.ToString();
                        fee.duedate = duedate;
                    }
                }
                else
                {
                    if (feestatus != FeePaymentStatus.UNKNOWN && !string.IsNullOrEmpty(feetotal))
                    {
                        var fee = new fee();
                        fee.name      = feetype.name;
                        fee.typeid    = feetypeid;
                        fee.studentid = userid;
                        fee.status    = feestatus.ToString();
                        fee.amount    = decimal.Parse(feetotal,
                                                      NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands);
                        fee.duedate = duedate;
                        db.fees.InsertOnSubmit(fee);
                    }
                }
            }

            try
            {
                repository.Save();
            }
            catch (Exception ex)
            {
                Syslog.Write(ex);
            }

            return(Json("Fees updated successfully".ToJsonOKMessage()));
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            fee fee = db.fees.Find(id);

            db.fees.Remove(fee);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
 public ActionResult Edit([Bind(Include = "feeID,feedesc,feeamount,duedate")] fee fee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(fee));
 }
Пример #4
0
        public ActionResult AddFee(string name, decimal amount, long studentid)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(Json("Name required".ToJsonFail()));
            }

            var newfee = new fee();

            newfee.name      = name;
            newfee.amount    = amount;
            newfee.studentid = studentid;
            newfee.status    = FeePaymentStatus.UNPAID.ToString();

            // need to find due date for this entry
            try
            {
                // fee could be added after reminder has been sent or before sending a reminder
                // sent => use earliest paymentdue date after today
                var reminder_duedate = db.fees.Where(x => x.studentid == studentid &&
                                                     x.status == FeePaymentStatus.UNPAID.ToString())
                                       .SelectMany(x => x.fees_reminders)
                                       .Where(x => x.paymentdue > DateTime.Now)
                                       .OrderBy(x => x.paymentdue)
                                       .FirstOrDefault();

                if (reminder_duedate != null)
                {
                    newfee.duedate = reminder_duedate.paymentdue;
                }
                else
                {
                    // ok get fees
                    newfee.duedate = db.fees.Where(x => x.studentid == studentid &&
                                                   x.status == FeePaymentStatus.UNPAID.ToString() &&
                                                   x.duedate < DateTime.Now)
                                     .OrderByDescending(x => x.duedate)
                                     .First()
                                     .duedate;
                }

                db.fees.InsertOnSubmit(newfee);
                repository.Save();
            }
            catch (Exception ex)
            {
                return(SendJsonErrorResponse(ex));
            }

            var viewmodel = newfee.ToModel(auth.perms);

            var view = this.RenderViewToString("FeesOverdue", new[] { viewmodel });

            return(Json(view.ToJsonOKData()));
        }
Пример #5
0
        public ActionResult Create([Bind(Include = "feeID,feedesc,feeamount,duedate")] fee fee)
        {
            if (ModelState.IsValid)
            {
                db.fees.Add(fee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(fee));
        }
 public ActionResult Edit([Bind(Include = "feeid,feeamount,date,StudentId")] fee fee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.StudentId = new SelectList(db.students, "StudentId", "Std_name", fee.StudentId);
     return(View(fee));
 }
        public ActionResult Create([Bind(Include = "feeid,feeamount,date,StudentId")] fee fee)
        {
            if (ModelState.IsValid)
            {
                db.fees.Add(fee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StudentId = new SelectList(db.students, "StudentId", "Std_name", fee.StudentId);
            return(View(fee));
        }
Пример #8
0
 public static SchoolFeeStudent ToModel(this fee row, Permission?permission)
 {
     return(new SchoolFeeStudent()
     {
         amount = row.amount,
         canEdit = permission.HasValue && ((Permission.FEES_UPDATE_STATUS | Permission.FEES_ADMIN) & permission.Value) != 0,
         id = row.id.ToString(),
         name = row.name,
         duedate = row.status != FeePaymentStatus.PAID.ToDescriptionString()? row.duedateWithReminders : (DateTime?)null,
         status = row.status.ToEnum <FeePaymentStatus>().ToDescriptionString(),
         warningsent = row.fees_reminders.Count()
     });
 }
Пример #9
0
 public JsonResult DeleteFee(long feeId)
 {
     try
     {
         fee feeItem = entities.fees.Find(feeId);
         entities.fees.Remove(feeItem);
         entities.SaveChanges();
         return(Json(new { result = "succes" }));
     } catch (Exception ex)
     {
         return(Json(new { result = "error", exception = ex.Message }));
     }
 }
Пример #10
0
        // post: api/fees
        public bool post(fee f)
        {
            var id = unitOfWork.FeesManager.MaxId(f);

            for (int i = 0; true; i++)
            {
                if (unitOfWork.FeesManager.GetByID(id) == null)
                {
                    f.id = id;
                    return(unitOfWork.FeesManager.AddEntity(f));
                }
                id++;
            }
        }
Пример #11
0
 public ActionResult Edit([Bind(Include = "fee_id,admission_fee_rs,st_fk_id,class_fk_id,suubject_fk_id,Fee_structure_id")] fee fee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.class_fk_id      = new SelectList(db.tbl_class, "class_id", "class_name", fee.class_fk_id);
     ViewBag.Fee_structure_id = new SelectList(db.Fee_structure, "fee_structure_id", "fee_structure_id", fee.Fee_structure_id);
     ViewBag.st_fk_id         = new SelectList(db.tbl_student, "stu_id", "applicant_name", fee.st_fk_id);
     ViewBag.suubject_fk_id   = new SelectList(db.tbl_subject, "sub_id", "sub_name", fee.suubject_fk_id);
     return(View(fee));
 }
Пример #12
0
        // GET: fees/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            fee fee = db.fees.Find(id);

            if (fee == null)
            {
                return(HttpNotFound());
            }
            return(View(fee));
        }
        // GET: fees/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            fee fee = db.fees.Find(id);

            if (fee == null)
            {
                return(HttpNotFound());
            }
            ViewBag.StudentId = new SelectList(db.students, "StudentId", "Std_name", fee.StudentId);
            return(View(fee));
        }
Пример #14
0
        // GET: fees/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            fee fee = db.fees.Find(id);

            if (fee == null)
            {
                return(HttpNotFound());
            }
            ViewBag.class_fk_id      = new SelectList(db.tbl_class, "class_id", "class_name", fee.class_fk_id);
            ViewBag.Fee_structure_id = new SelectList(db.Fee_structure, "fee_structure_id", "fee_structure_id", fee.Fee_structure_id);
            ViewBag.st_fk_id         = new SelectList(db.tbl_student, "stu_id", "applicant_name", fee.st_fk_id);
            ViewBag.suubject_fk_id   = new SelectList(db.tbl_subject, "sub_id", "sub_name", fee.suubject_fk_id);
            return(View(fee));
        }
Пример #15
0
        public ActionResult addfee(string fee_name, string cost, string taxCharge,
                                   string penalty, long bank_id, string merchant_account)
        {
            long userId  = (long)Session["USER_ID"];
            fee  feeItem = new fee();

            feeItem.name             = fee_name;
            feeItem.cost             = Convert.ToDecimal(cost);
            feeItem.bank_id          = bank_id;
            feeItem.merchant_account = merchant_account;
            feeItem.tax_charge       = Convert.ToDecimal(taxCharge);
            feeItem.penalty          = Convert.ToDecimal(penalty);
            feeItem.created_at       = DateTime.Now;
            feeItem.user_id          = userId;
            feeItem.community_id     = Convert.ToInt64(Session["CURRENT_COMU"]);
            entities.fees.Add(feeItem);


            entities.SaveChanges();
            return(Redirect(Url.Action("listado", "cuotas", new { area = "coadmin" })));
        }
Пример #16
0
        public ActionResult editfee(long feedId, string fee_name, string cost, string taxCharge,
                                    string penalty, long bank_id, string merchant_account)
        {
            long userId  = (long)Session["USER_ID"];
            fee  feeItem = entities.fees.Find(feedId);

            if (feeItem != null)
            {
                feeItem.name             = fee_name;
                feeItem.cost             = Convert.ToDecimal(cost);
                feeItem.bank_id          = bank_id;
                feeItem.merchant_account = merchant_account;
                feeItem.tax_charge       = Convert.ToDecimal(taxCharge);
                feeItem.penalty          = Convert.ToDecimal(penalty);
                entities.SaveChanges();
                return(Redirect(Url.Action("listado", "cuotas", new { area = "coadmin" })));
            }
            else
            {
                return(Redirect(ep.GetLogoutUrl()));
            }
        }
Пример #17
0
        public ActionResult editar(long?editID)
        {
            if (Session["USER_ID"] != null)
            {
                if (Session["CURRENT_COMU"] != null)
                {
                    if (editID != null)
                    {
                        try
                        {
                            long userId  = (long)Session["USER_ID"];
                            fee  feeItem = entities.fees.Where(m => m.id == editID).FirstOrDefault();
                            if (feeItem != null)
                            {
                                long                   communityAct   = Convert.ToInt64(Session["CURRENT_COMU"]);
                                user                   curUser        = entities.users.Find(userId);
                                List <bank>            bankList       = entities.banks.Where(m => m.user_id == userId).ToList();
                                List <ShowMessage>     pubMessageList = ep.GetChatMessages(userId);
                                agregarCuotasViewModel viewModel      = new agregarCuotasViewModel();

                                communityList           = ep.GetCommunityList(userId);
                                viewModel.communityList = communityList;

                                viewModel.side_menu              = "cuotas";
                                viewModel.side_sub_menu          = "cuotas_editar";
                                viewModel.document_category_list = entities.document_type.Where(x => x.community_id == communityAct).ToList();
                                viewModel.curUser         = curUser;
                                viewModel.pubTaskList     = ep.GetNotifiTaskList(userId);
                                viewModel.pubMessageList  = pubMessageList;
                                viewModel.messageCount    = ep.GetUnreadMessageCount(pubMessageList);
                                viewModel.feedId          = Convert.ToInt64(editID);
                                viewModel.bankList        = bankList;
                                viewModel.feeName         = feeItem.name;
                                viewModel.cost            = feeItem.cost;
                                viewModel.taxCharge       = feeItem.tax_charge;
                                viewModel.penalty         = feeItem.penalty;
                                viewModel.merchantAccount = feeItem.merchant_account;
                                viewModel.bankId          = feeItem.bank_id;
                                return(View(viewModel));
                            }
                            else
                            {
                                return(Redirect(Url.Action("listado", "cuotas", new { area = "coadmin", Error = "No existe ese elemento" })));
                            }
                        }
                        catch (Exception ex)
                        {
                            return(Redirect(Url.Action("Index", "Error")));
                        }
                    }
                    else
                    {
                        return(Redirect(Url.Action("NotFound", "Error")));
                    }
                }
                else
                {
                    return(Redirect(Url.Action("listado", "cuotas", new { area = "coadmin", Error = "No puede editar cuotas. Usted no administra ninguna comunidad. Comuníquese con el Webmaster..." })));
                }
            }
            else
            {
                return(Redirect(ep.GetLogoutUrl()));
            }
        }
        private void materialFlatButton2_Click(object sender, EventArgs e)
        {
            fee f = new fee();

            showContol(f);
        }
Пример #19
0
 // PUT: api/Fees/5
 public bool Put(fee f)
 {
     return(unitOfWork.FeesManager.UpdateEntity(f));
 }
Пример #20
0
        public async Task <ActionResult> MakePayment(decimal cost, decimal taxCharge, decimal penalty)
        {
            try
            {
                long       communityAct   = Convert.ToInt64(Session["CURRENT_COMU"]);
                string     paymentType    = "CC"; // CreditCard
                bool       makePayment    = false;
                long       userId         = (long)Session["USER_ID"];
                user       curUser        = entities.users.Find(userId);
                long       adminId        = (long)curUser.create_userid;
                fee        feeItem        = entities.fees.Where(m => m.user_id == adminId && m.community_id == communityAct).FirstOrDefault();
                bank       adminBankItem  = entities.banks.Find(feeItem.bank_id);
                string     bank_account   = adminBankItem.account_number;
                string     routing_number = adminBankItem.route_number;
                string     account_name   = adminBankItem.account_name;
                user       adminUser      = entities.users.Find(adminId);
                decimal    totalAmount    = cost + taxCharge + penalty;
                creditcard creditcardItem = entities.creditcards.Where(m => m.user_id == userId).FirstOrDefault();
                StripeConfiguration.SetApiKey(ep.GetStripeSecretKey());

                if (creditcardItem != null)
                {
                    DateTime expire_date = (DateTime)creditcardItem.expiration_date;
                    var      options     = new TokenCreateOptions
                    {
                        Card = new CreditCardOptions
                        {
                            Number   = creditcardItem.card_number, //"4000 0000 0000 0077", //creditcardItem.card_number,//"4242424242424242"
                            ExpYear  = expire_date.Year,           //2020
                            ExpMonth = expire_date.Month,
                            Cvc      = creditcardItem.ccv
                        }
                    };
                    var   service     = new TokenService();
                    Token stripeToken = service.Create(options);
                    int   pc          = await PaymentCredit(stripeToken.Id, Convert.ToInt32(cost * 100),
                                                            bank_account, routing_number, account_name);

                    if (pc == 1)
                    {
                        paymentType = "CC";
                        makePayment = true;
                    }
                }
                else
                {
                    bank userBank = entities.banks.Where(m => m.user_id == userId).FirstOrDefault();
                    if (userBank != null)
                    {
                        var options = new TokenCreateOptions
                        {
                            BankAccount = new BankAccountOptions
                            {
                                Country           = "US",
                                Currency          = "usd",
                                AccountHolderName = userBank.account_name,  //"Jenny Rosen"
                                AccountHolderType = "individual",
                                RoutingNumber     = userBank.route_number,  //"110000000"
                                AccountNumber     = userBank.account_number //"000123456789"
                            }
                        };
                        var   service     = new TokenService();
                        Token stripeToken = service.Create(options);
                        int   ach         = await PaymentAch(stripeToken.Id, Convert.ToInt32(totalAmount * 100),
                                                             bank_account, routing_number);

                        if (ach == 1)
                        {
                            paymentType = "ACH";
                            makePayment = true;
                        }
                    }
                }

                if (makePayment == true)
                {
                    transaction transItem = new transaction();

                    if (transItem.balance != null)
                    {
                        decimal originBalance = (decimal)transItem.balance;
                        transItem.balance = originBalance + totalAmount;
                    }
                    else
                    {
                        transItem.balance = totalAmount;
                    }
                    transItem.credit    = 0;
                    transItem.debit     = totalAmount;
                    transItem.date_info = DateTime.Now;
                    transItem.kind      = "Factura";
                    transItem.state     = "Factura";
                    transItem.trans_id  = "";
                    entities.transactions.Add(transItem);

                    payment paymentItem = new payment();
                    paymentItem.method       = paymentType;
                    paymentItem.date_issue   = DateTime.Now;
                    paymentItem.date_payment = null;
                    paymentItem.email        = adminUser.email;
                    paymentItem.first_name   = adminUser.first_name1;
                    paymentItem.surname      = adminUser.last_name1;
                    paymentItem.to_user_id   = adminId;
                    paymentItem.quantity     = totalAmount;
                    paymentItem.user_id      = userId;
                    paymentItem.state        = true;
                    entities.payments.Add(paymentItem);
                    entities.SaveChanges();
                }

                return(Redirect(Url.Action("estado", "cuotas")));
            }
            catch (Exception ex)
            {
                return(Redirect(Url.Action("balance", "cuotas")));
            }
        }