//
        // GET: /MemberTypeDiscount/Edit/5

        public ActionResult Edit(int id)
        {
            MemberTypeDiscountModel model = new MemberTypeDiscountModel();

            model = pro.GetObject(id);
            return(View(model));
        }
        public ActionResult Index()
        {
            MemberTypeDiscountModel model = new MemberTypeDiscountModel();

            model.memberDiscountTypes = pro.GetList();
            return(View(model));
        }
 public MemberTypeDiscountModel GetObject(int id)
 {
     using (EHMSEntities ent = new EHMSEntities())
     {
         var obj = ent.SetupMemberDiscounts.Where(x => x.MemberDiscountID == id).FirstOrDefault();
         MemberTypeDiscountModel model = AutoMapper.Mapper.Map <SetupMemberDiscount, MemberTypeDiscountModel>(obj);
         return(model);
     }
 }
 public void Update(MemberTypeDiscountModel model)
 {
     using (EHMSEntities ent = new EHMSEntities())
     {
         var objtoedit = ent.SetupMemberDiscounts.Where(x => x.MemberDiscountID == model.MemberDiscountID).FirstOrDefault();
         model.CreatedDate = objtoedit.CreatedDate;
         model.CreatedBy   = objtoedit.CreatedBy;
         AutoMapper.Mapper.Map(model, objtoedit);
         objtoedit.Status           = "A";
         ent.Entry(objtoedit).State = System.Data.EntityState.Modified;
         ent.SaveChanges();
     }
 }
        public void Insert(MemberTypeDiscountModel model)
        {
            using (EHMSEntities ent = new EHMSEntities())
            {
                var objToSave = AutoMapper.Mapper.Map <MemberTypeDiscountModel, SetupMemberDiscount>(model);

                objToSave.Status      = "A";
                objToSave.CreatedDate = DateTime.Now;
                objToSave.CreatedBy   = 1;
                ent.SetupMemberDiscounts.Add(objToSave);
                ent.SaveChanges();
            }
        }
 public ActionResult Edit(int id, MemberTypeDiscountModel model)
 {
     try
     {
         // TODO: Add update logic here
         if (ModelState.IsValid)
         {
             pro.Update(model);
             TempData["success"] = "Record Updated Successfully !";
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(model));
         }
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(MemberTypeDiscountModel model)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             pro.Insert(model);
             TempData["success"] = "Record Created Successfully !";
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(model));
         }
     }
     catch
     {
         return(View());
     }
 }
        //
        // GET: /MemberTypeDiscount/Create

        public ActionResult Create()
        {
            MemberTypeDiscountModel model = new MemberTypeDiscountModel();

            return(View(model));
        }