public string EditCustomerVoucher(CustomerVoucher Model, FormCollection form)
        {
            string statusDDLValue = form["VoucherName"].ToString();
            string msgClient;

            try
            {
                if (ModelState.IsValid)
                {
                    var enditedCustomerVoucherValue = new LMS_Datas.CustomerVoucher
                    {
                        Active     = true,
                        CustomerId = Model.CustomerId,
                        VoucherId  = Model.VoucherId,
                        AssignNo   = Model.AssignNo
                    };

                    entity.CustomerVouchers.Attach(enditedCustomerVoucherValue);

                    entity.Entry(enditedCustomerVoucherValue).State = EntityState.Modified;
                    entity.SaveChanges();
                    msgClient = "Saved Successfully";
                }
                else
                {
                    msgClient = "Validation data not successfully";
                }
            }
            catch (Exception ex)
            {
                msgClient = "Error in Retriving Data";
            }
            return(msgClient);
        }
        public ActionResult Index(CustomerVoucher model, FormCollection form)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string customerName = (from e in entity.Customers where e.CustomerId == model.CustomerId select e.Name).First().ToString();
                    string mobileNumber = (from e in entity.Customers where e.CustomerId == model.CustomerId select e.MobileNo).First().ToString();
                    mobileNumber = mobileNumber.Replace("(", String.Empty);
                    mobileNumber = mobileNumber.Replace(")", String.Empty);
                    mobileNumber = mobileNumber.Replace("-", String.Empty);
                    mobileNumber = mobileNumber.Replace(" ", String.Empty);
                    string vouchername = (from e in entity.Vouchers where e.VoucherId == model.VoucherId select e.VoucherName).First().ToString();
                    string mailId      = (from e in entity.Customers where e.CustomerId == model.CustomerId select e.EmailId).First().ToString();
                    using (var context = new LoyaltyManagementSystemEntities())
                    {
                        var addCustomerVoucher = new LMS_Datas.CustomerVoucher()
                        {
                            CustomerId = model.CustomerId,
                            VoucherId  = model.VoucherId,
                            AssignNo   = model.AssignNo,
                            AssignOn   = DateTime.Now,
                            Active     = true
                        };
                        context.CustomerVouchers.Add(addCustomerVoucher);

                        //context.ClientDetails.Add(clientDetails);
                        //etc add your other classes
                        context.SaveChanges();
                    }
                    ViewBag.CustomerId = new SelectList(entity.Customers.Where(models => models.Active == true), "CustomerId", "Name");
                    ViewBag.VoucherId  = new SelectList(entity.Vouchers.Where(models => models.Activate == true), "VoucherId", "VoucherName");
                    ViewBag.alert      = "Success";
                    builder.Append("Hello " + customerName + ",").AppendLine();
                    builder.Append("Voucher " + vouchername + " is assigned to you. Use Voucher No. " + model.AssignNo + " for further references.").AppendLine();
                    builder.Append("Thanks");
                    //sms.send(mobileNumber, builder);
                    sms.send("8285601519", builder);
                    Mail.send(builder, "*****@*****.**", "*****@*****.**", "Voucher Assigned");
                }
            }
            catch (Exception e1)
            {
                ViewBag.alert = "Error";
            }
            return(View());
        }