public string DeleteCustomerVoucher(Voucher Model)
        {
            string msg;

            try
            {
                if (ModelState.IsValid)
                {
                    var enditedValue = new LMS_Datas.Voucher
                    {
                        Activate    = false,
                        VoucherId   = Model.VoucherId,
                        VoucherName = Model.VoucherName,
                        ValidFrom   = Model.ValidFrom,
                        ValidTo     = Model.ValidTo,
                        description = Model.description
                    };
                    entity.Entry(enditedValue).State = EntityState.Modified;
                    entity.SaveChanges();
                    msg = "Delete Successfully";
                }
                else
                {
                    msg = "Validation data not successfully";
                }
            }
            catch (Exception e1)
            {
                msg = "Validation data not successfully";
            }
            return(msg);
        }
示例#2
0
        public string DeleteVoucher(int Id)
        {
            string msg;

            try
            {
                if (ModelState.IsValid)
                {
                    var enditedValue = new LMS_Datas.Voucher
                    {
                        VoucherId = Id,
                        Activate  = false
                    };
                    entity.Entry(enditedValue).State = EntityState.Modified;
                    entity.Entry(enditedValue).Property(x => x.PackagesId).IsModified  = false;
                    entity.Entry(enditedValue).Property(x => x.ValidFrom).IsModified   = false;
                    entity.Entry(enditedValue).Property(x => x.ValidTo).IsModified     = false;
                    entity.Entry(enditedValue).Property(x => x.VoucherName).IsModified = false;
                    entity.SaveChanges();
                    msg = "Delete Successfully";
                }
                else
                {
                    msg = "Validation data not successfully";
                }
            }
            catch (Exception e1)
            {
                msg = "Validation data not successfully";
            }
            return(msg);
        }
示例#3
0
        public ActionResult Index(Voucher model, FormCollection form)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string statusDDLValue = form["Statusddl"].ToString();
                    using (var context = new LoyaltyManagementSystemEntities())
                    {
                        var addVoucher = new LMS_Datas.Voucher()
                        {
                            Activate    = true,
                            description = model.description,
                            Discountper = model.Discountper,
                            ValidFrom   = model.ValidFrom,
                            ValidTo     = model.ValidTo,
                            VoucherName = model.VoucherName,
                            PackagesId  = model.PackagesId,
                            persons     = model.persons
                        };
                        context.Vouchers.Add(addVoucher);

                        //context.ClientDetails.Add(clientDetails);
                        //etc add your other classes
                        context.SaveChanges();
                    }
                    ViewBag.PackageDd = new SelectList(entity.Packages.Where(models => models.Active == true), "PackagesId", "PackageName");
                    ViewBag.alert     = "Success";
                }
            }
            catch (Exception e1)
            {
                ViewBag.alert = "Error";
            }
            return(View());
        }
示例#4
0
        // Admin is Client Here
        public string EditVoucher(Voucher Model)
        {
            string msgClient;

            try
            {
                if (ModelState.IsValid)
                {
                    var enditedVoucherValue = new LMS_Datas.Voucher
                    {
                        Activate    = true,
                        VoucherName = Model.VoucherName,
                        description = Model.description,
                        ValidFrom   = Model.ValidFrom,
                        ValidTo     = Model.ValidTo,
                        VoucherId   = Model.VoucherId,
                        persons     = Model.persons
                    };

                    entity.Vouchers.Attach(enditedVoucherValue);

                    entity.Entry(enditedVoucherValue).State = EntityState.Modified;
                    entity.SaveChanges();
                    msgClient = "Saved Successfully";
                }
                else
                {
                    msgClient = "Validation data not successfully";
                }
            }
            catch (Exception ex)
            {
                msgClient = "Error in Retriving Data";
            }
            return(msgClient);
        }