コード例 #1
0
        public string DeleteClient(LMS_Datas.Desk Model)
        {
            string msg;

            //try
            //{
            //    if (ModelState.IsValid)
            //    {
            //        var enditedValue = new LMS_Datas.Admin
            //        {
            //            Active = false,
            //            AdminId = Model.AdminId,
            //            Address = Model.Address,
            //            EmailId = Model.EmailId,
            //            dob = Model.dob
            //        };
            //        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("Hello");
        }
コード例 #2
0
        public string EditClient(LMS_Datas.Desk Model)
        {
            string msgClient;

            try
            {
                if (ModelState.IsValid)
                {
                    var enditedDeskValue = new LMS_Datas.Desk
                    {
                        Active   = true,
                        AdminId  = Model.AdminId,
                        DeskName = Model.DeskName,
                        UserName = Model.UserName,
                        Password = Model.Password
                    };

                    entity.Desks.Attach(enditedDeskValue);
                    //entity.Entry(enditedDeskValue).Property(x => x.cityId).IsModified = false;
                    //entity.Entry(enditedDeskValue).Property(x => x.stateId).IsModified = false;
                    //entity.Entry(enditedDeskValue).Property(x => x.dob).IsModified = false;
                    //entity.Entry(enditedDeskValue).Property(x => x.gender).IsModified = false;
                    //entity.Entry(enditedDeskValue).Property(x => x.countryId).IsModified = false;
                    //entity.Entry(enditedDeskValue).Property(x => x.Name).IsModified = true;
                    //entity.Entry(enditedDeskValue).Property(x => x.EmailId).IsModified = true;
                    //entity.Entry(enditedDeskValue).Property(x => x.MobileNo).IsModified = true;
                    //entity.Entry(enditedValue).State = EntityState.Modified;
                    entity.SaveChanges();

                    int?loginid = (from loginId in entity.Logins where loginId.UserId == Model.AdminId select loginId.UserId).FirstOrDefault();
                    var enditedAdminLoginValue = new Login
                    {
                        UserName = Model.UserName,
                        Password = Model.Password,
                        UserId   = loginid,
                        Activate = "true"
                    };

                    entity.Logins.Attach(enditedAdminLoginValue);
                    entity.Entry(enditedAdminLoginValue).State = EntityState.Modified;
                    entity.SaveChanges();
                    msgClient = "Saved Successfully";
                }
                else
                {
                    msgClient = "Validation data not successfully";
                }
            }
            catch (Exception ex)
            {
                msgClient = "Error in Retriving Data";
            }
            return(msgClient);
        }
コード例 #3
0
        public ActionResult Index(LMS_Datas.Desk model, FormCollection form, HttpPostedFileBase files)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var context = new LoyaltyManagementSystemEntities())
                    {
                        var addDesk = new LMS_Datas.Desk()
                        {
                            DeskName = model.DeskName,
                            Password = model.Password,
                            DeskNo   = model.DeskNo,
                            Active   = model.Active,
                            UserName = model.UserName
                        };
                        context.Desks.Add(addDesk);

                        context.SaveChanges();

                        if (files.FileName != null)
                        {
                            var    ext    = Path.GetExtension(files.FileName);
                            string myfile = addDesk.DeskId + ext;
                            var    path   = Path.Combine(Server.MapPath("~/Images/DeskProfile"), myfile);
                            files.SaveAs(path);
                        }
                    }
                    ViewBag.alert = "Success";
                    return(View());
                }
                ViewBag.alert = "Error";
                return(View(model));
            }
            catch (Exception e1)
            {
                ViewBag.alert = "Error";
                return(View());
            }
        }