Пример #1
0
        public ActionResult Index(Package model, FormCollection form)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string statusDDLValue = form["Statusddl"].ToString();

                    //var clientId= entity.InsertUpdateSelectAdmin(0, model.name, model.Address, model.MobileNo, model.EmailId, genderDDLValue, model.dob, model.countryId, model.stateId, model.cityId, 1, );
                    using (var context = new LoyaltyManagementSystemEntities())
                    {
                        var package = new LMS_Datas.Package()
                        {
                            PackageName = model.PackageName,
                            Description = model.Description,
                            Active      = Boolean.Parse(statusDDLValue)
                        };
                        context.Packages.Add(package);

                        //context.ClientDetails.Add(clientDetails);
                        //etc add your other classes
                        context.SaveChanges();
                    }
                    ViewBag.alert = "Success";
                    return(View());
                }
                ViewBag.alert = "Error";
                return(View(model));
            }
            catch (Exception e1)
            {
                ViewBag.alert = "Error";
                return(View());
            }
        }
Пример #2
0
        public string EditPackage(Package Model)
        {
            string msgClient;

            try
            {
                if (ModelState.IsValid)
                {
                    var enditedPackageValue = new LMS_Datas.Package
                    {
                        Active      = true,
                        PackageName = Model.PackageName,
                        Description = Model.Description,
                        PackagesId  = Model.PackagesId
                    };

                    entity.Packages.Attach(enditedPackageValue);
                    entity.Entry(enditedPackageValue).Property(x => x.Active).IsModified      = true;
                    entity.Entry(enditedPackageValue).Property(x => x.PackagesId).IsModified  = true;
                    entity.Entry(enditedPackageValue).Property(x => x.Description).IsModified = true;
                    entity.Entry(enditedPackageValue).Property(x => x.PackageName).IsModified = true;
                    //entity.Entry(enditedPackageValue).State = EntityState.Modified;
                    entity.SaveChanges();
                    msgClient = "Saved Successfully";
                }
                else
                {
                    msgClient = "Validation data not successfully";
                }
            }
            catch (Exception ex)
            {
                msgClient = "Error in Retriving Data";
            }
            return(msgClient);
        }