Beispiel #1
0
        public IActionResult ListSettlementInformation()
        {
            //TODO: change to current user Id
            var currentUserId = 1;

            var userCredibilities = GenerateUserCredibilities(currentUserId);
            var userLiabilities   = GenerateUserLiabilities(currentUserId);

            var settlementVM = new SettlementViewModel
            {
                UserCredibilities = userCredibilities,
                UserLiabilities   = userLiabilities
            };

            return(PartialView("_settlementPartial", settlementVM));
        }
        public ActionResult Edit(SettlementViewModel settlementvm)
        {
            if (ModelState.IsValid)
            {
                if (settlementvm.ExpensesReport == null)
                {
                    var cia = _db.CashInAdvances.Find(settlementvm.CashInAdvance.Id);
                    if (cia == null)
                    {
                        return(HttpNotFound());
                    }
                    cia.SettledAmount      = settlementvm.CashInAdvance.SettledAmount;
                    cia.SettlementDate     = DateTime.Now.Date;
                    cia.OperationsComment  = settlementvm.CashInAdvance.OperationsComment;
                    cia.CashInAdvanceStatu = _db.CashInAdvanceStatus.Find(settlementvm.CashInAdvance.CashInAdvanceStatus);

                    _db.SaveChanges();
                }
                else
                {
                    var exp = _db.ExpensesReports.Find(settlementvm.ExpensesReport.ID);
                    if (exp == null)
                    {
                        return(HttpNotFound());
                    }
                    exp.SettledAmount      = settlementvm.ExpensesReport.SettledAmount;
                    exp.SettlementDate     = DateTime.Now.Date;
                    exp.OperationsComment  = settlementvm.ExpensesReport.OperationsComment;
                    exp.ExpenseReportStatu = _db.ExpenseReportStatus.Find(settlementvm.ExpensesReport.StatusID);

                    if (settlementvm.CashInAdvance != null)
                    {
                        var cia = _db.CashInAdvances.Find(settlementvm.CashInAdvance.Id);
                        if (cia != null)
                        {
                            cia.CashInAdvanceStatu = _db.CashInAdvanceStatus.Find(settlementvm.CashInAdvance.CashInAdvanceStatus);
                            _db.SaveChanges();
                        }
                    }

                    _db.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            return(View(settlementvm));
        }
Beispiel #3
0
        public IActionResult ListCurrentSettlementInformation()
        {
            //TODO: change to current user Id
            var currentUserId = 1;

            var userCredibilities = GenerateCurrentUserCredibilities(currentUserId);
            var userLiabilities   = GenerateCurrentUserLiabilities(currentUserId);

            userCredibilities.Sort((a, b) => { return(DateTime.Compare(b.FinalizationDate, a.FinalizationDate)); });
            userLiabilities.Sort((a, b) => { return(DateTime.Compare(b.FinalizationDate, a.FinalizationDate)); });

            var settlementVM = new SettlementViewModel
            {
                UserCredibilities = userCredibilities,
                UserLiabilities   = userLiabilities
            };

            return(PartialView("_listCurrentExpensesPartial", settlementVM));
        }
        // GET: NonTrips/Edit/5
        public ActionResult Edit(int?expid, int?ciaId)
        {
            if (expid == null && ciaId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var settlementvm = new SettlementViewModel();

            if (expid == null)
            {
                var cia = _db.CashInAdvances.Find(ciaId);
                if (cia == null)
                {
                    return(HttpNotFound());
                }
                settlementvm.CashInAdvance  = cia;
                settlementvm.ExpensesReport = null; // did so for the nullity check in the edit view
            }
            else
            {
                var exp = _db.ExpensesReports.Find(expid);
                if (exp == null)
                {
                    return(HttpNotFound());
                }
                if (ciaId != null)
                {
                    var cia = _db.CashInAdvances.Find(ciaId);
                    settlementvm.CashInAdvance = cia;
                }
                settlementvm.ExpensesReport = exp;
            }
            ViewBag.CIAStatuses     = new SelectList(_db.CashInAdvanceStatus.ToList(), "ID", "CashInAdvanceStatus");
            ViewBag.ExpenseStatuses = new SelectList(_db.ExpenseReportStatus.ToList(), "StatusID", "StatusName");
            return(View(settlementvm));
        }