Пример #1
0
        public ActionResult Edit(SettingModel setting_m)
        {
            foreach (var secctions in setting_m.Settings)
            {
                foreach (var setting_new in secctions.Value)
                {
                    settings setting = db.settings.Where(w => w.slug == setting_new.slug).SingleOrDefault();

                    if (setting != null)
                    {
                        if (setting_new.values != null)
                        {
                            setting.value = String.Join(",", setting_new.values);// setting_new.values.Join(",");
                        }
                        else
                        {
                            setting.value = setting_new.value;
                        }

                        db.Entry(setting).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }

            /* if (ModelState.IsValid)
             * {
             *   db.Entry(setting).State = EntityState.Modified;
             *   db.SaveChanges();
             *   return RedirectToAction("Index");
             * }*/
            //return View(setting);
            FlashData.SetFlashData("success", "Tu configuración ha sido guardada.");
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public ActionResult Edit(int id, AreaModel area_m)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    cat_areas area = new cat_areas();
                    area.id        = area_m.id;
                    area.id_centro = area_m.id_centro;
                    area.nombre    = area_m.nombre;

                    db.Entry(area).State = EntityState.Modified;
                    db.SaveChanges();
                    FlashData.SetFlashData("success", "Registro modificado satisfactoriamente");
                    return(RedirectToAction("Index"));
                }
                return(ViewBag(area_m));
            }
            catch (Exception ex)
            {
                FlashData.SetFlashData("error", ex.Message);
                return(RedirectToAction("Index"));
            }
        }
Пример #3
0
        public ActionResult Save(PermissionModel permissions_m)
        {
            List <string> items = new List <string>();

            foreach (var module in permissions_m.list_module_m)
            {
                if (module.slug != null)
                {
                    var permission = db.permissions.Where(w => w.group_id == permissions_m.group_id)
                                     .Where(w => w.module == module.slug).SingleOrDefault();


                    if (permission == null)
                    {
                        db.permissions.Add(new permissions {
                            group_id = permissions_m.group_id, module = module.slug, roles = module.roles != null ? System.Web.Helpers.Json.Encode(module.roles) : null
                        });
                        db.SaveChanges();
                    }
                    else
                    {
                        //db.permissions.e(new permission { group_id = permissions_m.group_id, module = module.slug, roles = System.Web.Helpers.Json.Encode(module.roles) });
                        permissions permission_update = (permissions)permission;

                        permission_update.roles = module.roles != null?System.Web.Helpers.Json.Encode(module.roles) : null;

                        db.Entry(permission_update).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    items.Add(module.slug);
                }
            }
            List <permissions> list_delete = new List <permissions>();

            if (items.Count > 0)
            {
                list_delete = db.permissions.Where(w => w.group_id == permissions_m.group_id)
                              .Where(w => !items.Contains(w.module))
                              .ToList();
            }
            else
            {
                list_delete = db.permissions.Where(w => w.group_id == permissions_m.group_id)
                              .ToList();
            }
            if (list_delete != null)
            {
                foreach (var enty in list_delete.ToList())
                {
                    db.permissions.Remove(enty);
                    db.SaveChanges();
                }
            }


            //return Content("");
            return(RedirectToAction("Save", "Permissions", new { id = permissions_m.group_id }));
        }
Пример #4
0
 public ActionResult Edit(centros centros)
 {
     if (ModelState.IsValid)
     {
         db.Entry(centros).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(centros));
 }
Пример #5
0
        public static void SetLastLogin(int id)
        {
            rekursosEntities db   = new rekursosEntities();
            users            user = db.users.Find(id);

            user.last_login = DateTime.Now;

            db.Entry(user).State = EntityState.Modified;
            db.SaveChanges();
        }
Пример #6
0
        public ActionResult Edit(int id, alumnos alumno, HttpPostedFileBase fotografia)
        {
            try
            {
                if (fotografia != null)
                {
                    var result = Libraries.File.upload(fotografia, 1);

                    if (result.status)
                    {
                        alumno.fotografia = result.data.id;
                    }
                }
                db.Entry(alumno).State = EntityState.Modified;
                db.SaveChanges();
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #7
0
        // PUT api/Default1/5
        public HttpResponseMessage Putcat_localidades(int id, cat_localidades cat_localidades)
        {
            if (ModelState.IsValid && id == cat_localidades.id)
            {
                db.Entry(cat_localidades).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Пример #8
0
        public ActionResult Edit(UserModel user_m)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    users user = db.users.Find(user_m.id);


                    user.id           = user_m.id;
                    user.group_id     = user_m.group_id;
                    user.active       = user_m.active;
                    user.email        = user_m.email;
                    user.username     = user_m.username;
                    user.display_name = user_m.display_name;

                    if (user_m.password != null && user_m.password != "")
                    {
                        user.password = Sha1.SHA1HashStringForUTF8String(user_m.password);
                    }

                    db.Entry(user).State = EntityState.Modified;
                    db.SaveChanges();
                    FlashData.SetFlashData("success", "La cuenta del usuario ha sido modificado satisfactoriamente");


                    return(RedirectToAction("Index"));
                }

                ViewBag.group_id = new SelectList(db.groups, "id", "description", user_m.group_id);
                return(View(user_m));
            }
            catch (Exception ex)
            {
                FlashData.SetFlashData("error", ex.Message);
                return(RedirectToAction("Index"));
            }
        }
Пример #9
0
        public ActionResult Save(UserModel user_m, string tab = "profile")
        {
            users update = new users();
            users user   = Ion_Auth.GetUser(User.Identity.Name, false);

            update.id         = user.id;
            update.group_id   = user.group_id;
            update.password   = user.password;
            update.active     = user.active;
            update.created_on = user.created_on;
            update.last_login = user.last_login;
            update.username   = user.username;

            update.display_name = user.display_name;
            update.email        = user.email;


            switch (tab)
            {
            case "profile":

                update.email        = user_m.email;
                update.display_name = user_m.display_name;
                //update.password = user.password;
                break;

            case "password":
                if (user_m.old_password != "" && Sha1.SHA1HashStringForUTF8String(user_m.old_password) != user.password)
                {
                    ModelState.AddModelError("Error", "La antigua contraseña es inválida.");
                }
                if (user_m.new_password != user_m.retype_password)
                {
                    ModelState.AddModelError("Error1", "La nueva contraseña no coinciden.");
                }
                else
                {
                    update.password = Sha1.SHA1HashStringForUTF8String(user_m.new_password);
                }
                break;
            }
            if (ModelState.IsValid)
            {
                //user.groups = null;
                db.Entry(update).State = EntityState.Modified;
                db.SaveChanges();

                FlashData.SetFlashData("success", "Tu cuenta ha sido modificada satisfactoriamente");
            }
            else
            {
                string errors = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        errors += error.ErrorMessage + "\n";
                    }
                }

                if (errors != "")
                {
                    FlashData.SetFlashData("error", errors);
                }
            }
            return(RedirectToAction("Details"));
        }
Пример #10
0
        public ActionResult Edit(EmpleadoModel empleado_m)
        {
            if (ModelState.IsValid)
            {
                empleados empleado = new empleados();

                empleado.id               = empleado_m.id;
                empleado.id_empleado      = empleado_m.id_empleado;
                empleado.nombre           = empleado_m.nombre;
                empleado.apellido_paterno = empleado_m.apellido_paterno;
                empleado.apellido_materno = empleado_m.apellido_materno;
                empleado.fecha_nacimiento = empleado_m.fecha_nacimiento;
                empleado.id_area          = empleado_m.id_area;
                empleado.id_centro        = empleado_m.id_centro;
                empleado.cargo            = empleado_m.cargo;
                empleado.tipo_mando       = empleado_m.tipo_mando;
                empleado.rfc              = empleado_m.rfc;
                empleado.curp             = empleado_m.curp;
                empleado.direccion        = empleado_m.direccion;
                empleado.telefono         = empleado_m.telefono;
                empleado.email            = empleado_m.email;
                empleado.activo           = empleado_m.activo;
                empleado.fotografia       = empleado_m.fotografia;

                HttpPostedFileBase file = Request.Files["fotografia"];


                var result_camera = Libraries.File.SaveCamera(empleado_m.camera, 1);

                if (result_camera.status)
                {
                    empleado.fotografia = result_camera.data.id;
                }
                if (file != null && file.ContentLength > 0)
                {
                    //Response.Write(file.ContentLength);
                    var result = Libraries.File.upload(file, 1);

                    if (result.status)
                    {
                        empleado.fotografia = result.data.id;
                    }
                }


                db.Entry(empleado).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.id_area    = new SelectList(db.cat_areas, "id", "nombre");
            ViewBag.id_centro  = new SelectList(db.centros, "id", "nombre");
            ViewBag.tipo_mando = new SelectList(new List <SelectListItem> {
                //new SelectListItem { Text="[Seleccione]",Value="" },
                new SelectListItem {
                    Text = "Operativo", Value = "operativo"
                },
                new SelectListItem {
                    Text = "Medio", Value = "medio"
                },
                new SelectListItem {
                    Text = "Superior", Value = "superior"
                },
            }, "Value", "Text");
            return(View(empleado_m));
        }