using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Petrol_Bunk.Models;
namespace Petrol_Bunk.Areas.Admin.Controllers
{
    public class ExpenditureController : Controller
    {
        // GET: Admin/Expenditure/AddExpensive
        public ActionResult AddParticulars()
        {
            ViewBag.PartiMsg = TempData["PartiMsg"] == null ? "" : TempData["PartiMsg"] as string;
            return View();
        }
        public ActionResult AddParticulars_Post(TblParticular obj)
        {
            Petrol_BunkEntities ctx = new Petrol_BunkEntities();
            obj.RowStatus = 0;
            obj.InsertedDate = DateTime.Now;
            ctx.TblParticulars.Add(obj);
            if (ctx.SaveChanges() > 0)
            {
                TempData["PartiMsg"] = "Added Particulars";
            }
            else
            {
                TempData["PartiMsg"] = "Try Again";
            }
            return new RedirectResult("/Admin/Expenditure/AddParticulars");
        }

        public ActionResult AddExpensive()
        {
            ViewBag.ExpMsg = TempData["ExpMsg "] == null ? "" : TempData["ExpMsg "] as string;
            Petrol_BunkEntities ctx = new Petrol_BunkEntities();
            ViewBag.Particulars = new SelectList(ctx.TblParticulars.Where(x => x.RowStatus == 0).ToList(), "Particulars", "Particulars");
            return View();
        }
        public ActionResult AddExpensive_Post(TblExpensive obj)
        {
            Petrol_BunkEntities ctx = new Petrol_BunkEntities();

            obj.RowStatus = 0;
            obj.InsertedDate = DateTime.Now;
            obj.PaidDate = DateTime.Now;
            ctx.TblExpensives.Add(obj);
            if(ctx.SaveChanges()>0)
            {
                TempData["ExpMsg "] = "Added Expensives";
            }
            else
            {
                TempData["ExpMsg "] = "Try Again";
            }
            return new RedirectResult("/Admin/Expenditure/AddExpensive");
        }
    }
}