public ActionResult Edit(int id)
        {
            List <AdvancePaymentItem> objPay = new List <AdvancePaymentItem>();

            objPayItem = new AdvancePaymentItem();
            int cid = 0;

            if (Session["CompID"] != null)
            {
                cid = Convert.ToInt32(Session["CompID"].ToString());
            }
            objPayItem = objPayService.GetById(id);
            objPay     = objPayService.GetPaymentDetails(cid);
            objPayItem.ListAdvPayment = new List <AdvancePaymentItem>();
            objPayItem.ListAdvPayment.AddRange(objPay);

            #region Bind DropDown Comp
            List <CompanyItem> lstComp = new List <CompanyItem>();
            lstComp             = objPayService.GetAllComp();
            objPayItem.ListComp = new List <CompanyItem>();
            objPayItem.ListComp.AddRange(lstComp);
            #endregion

            #region Bind DropDown Emp
            List <EmployeeItem> lstEmp = new List <EmployeeItem>();
            lstEmp             = objPayService.GetEmp(cid);
            objPayItem.ListEmp = new List <EmployeeItem>();
            objPayItem.ListEmp.AddRange(lstEmp);
            #endregion

            return(View(objPayItem));
        }
        public ActionResult Create(AdvancePaymentItem model)
        {
            objPayService = new AdvancePaymentService();
            objPayItem    = new AdvancePaymentItem();
            objPayService.Insert(model);

            #region Bind DropDown Comp
            List <CompanyItem> lstComp = new List <CompanyItem>();
            lstComp             = objPayService.GetAllComp();
            objPayItem.ListComp = new List <CompanyItem>();
            objPayItem.ListComp.AddRange(lstComp);
            #endregion
            int cid = 0;
            if (Session["CompID"] != null)
            {
                cid = Convert.ToInt32(Session["CompID"].ToString());
            }
            #region Bind DropDown Emp
            List <EmployeeItem> lstEmp = new List <EmployeeItem>();
            lstEmp             = objPayService.GetEmp(cid);
            objPayItem.ListEmp = new List <EmployeeItem>();
            objPayItem.ListEmp.AddRange(lstEmp);
            #endregion

            List <AdvancePaymentItem> objPay = new List <AdvancePaymentItem>();
            objPay = objPayService.GetPaymentDetails(cid);
            objPayItem.ListAdvPayment = new List <AdvancePaymentItem>();
            objPayItem.ListAdvPayment.AddRange(objPay);
            return(RedirectToAction("Create"));
        }
        public ActionResult Edit(AdvancePaymentItem Model)
        {
            AdvancePaymentService objPayService = new AdvancePaymentService();
            AdvancePaymentItem    objPayItem    = new AdvancePaymentItem();

            objPayService.Update(Model);
            return(RedirectToAction("Create"));
        }
        public int Update(AdvancePaymentItem model)
        {
            //  model.CreatedDate = System.DateTime.Now;
            model.UpdatedDate = System.DateTime.Now;
            Mapper.CreateMap <AdvancePaymentItem, Advance_Payroll_Master>();
            Advance_Payroll_Master objRep = DbContext.Advance_Payroll_Master.SingleOrDefault(m => m.Id == model.Id);

            objRep = Mapper.Map(model, objRep);
            return(DbContext.SaveChanges());
        }
        public int Insert(AdvancePaymentItem model)
        {
            Advance_Payroll_Master objPayItem = new Advance_Payroll_Master();

            objPayItem.CompId      = model.CompId;
            objPayItem.EmpId       = model.EmpId;
            objPayItem.AdvAmount   = model.AdvAmount;
            objPayItem.CreatedDate = System.DateTime.Now;
            objPayItem.UpdatedDate = System.DateTime.Now;
            DbContext.Advance_Payroll_Master.Add(objPayItem);
            return(DbContext.SaveChanges());
        }
 public AdvancePaymentItem GetById(int id)
 {
     try
     {
         Mapper.CreateMap <Advance_Payroll_Master, AdvancePaymentItem>();
         Advance_Payroll_Master objAdvance     = DbContext.Advance_Payroll_Master.SingleOrDefault(m => m.Id == id);
         AdvancePaymentItem     objAdvanceItem = Mapper.Map <AdvancePaymentItem>(objAdvance);
         return(objAdvanceItem);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }