public JsonResult GetCategoriaDeporte(int IdDeporte) { MeSysEntities db1 = new MeSysEntities(); List <Categorias> lm = db1.Categorias.Where(x => x.ID_Deporte == IdDeporte).ToList(); return(Json(lm, JsonRequestBehavior.AllowGet)); }
public JsonResult GetMunicipiosPorDpto(int IdDpto) { MeSysEntities db1 = new MeSysEntities(); List <Municipio> lm = db1.Municipio.Where(x => x.ID_Departamento == IdDpto).ToList(); return(Json(lm, JsonRequestBehavior.AllowGet)); }
//Tal como lo platicas puedes crear un método que regrese un booleano y consumirlo con jQuery Ajax. //El método en MVC sería algo así: public bool TienePropositos(string nombre) { using (var db = new MeSysEntities()) { return(db.Datos_Atleta.Any(x => x.Nombre_Completo == nombre)); } }
public ActionResult Index(LoginViewModel usermodel) { if (ModelState.IsValid) { using (MeSysEntities db = new MeSysEntities()) { string Pwd = SHA256(usermodel.Contraseña); var obj = db.Usuarios.Where(a => a.Correo.Equals(usermodel.Correo) && a.Contraseña.Equals(Pwd)).FirstOrDefault(); if (usermodel.Correo == null && usermodel.Contraseña == null) { //usermodel.LoginErrorMessage = "Correo y Contraseña no pueden estar vacios"; return(View("Index", usermodel)); } else { if (usermodel.Correo == null) { //usermodel.LoginErrorMessage = "Campo Correo No puede estar vacio"; return(View("Index", usermodel)); } else if (usermodel.Contraseña == null) { //usermodel.LoginErrorMessage = "Campo Contraseña No puede estar vacio"; return(View("Index", usermodel)); } else { if (obj != null) { if (obj.ID_Rol.ToString() == Convert.ToString("1")) { Session["ID"] = obj.ID.ToString(); Session["Nombre"] = obj.Nombre.ToString(); Session["ID_Rol"] = obj.ID_Rol.ToString(); Session["Correo"] = obj.Correo.ToString(); //FormsAuthentication.SetAuthCookie(obj.ID_Rol.ToString(), false); return(Redirect("~/HomeAdmin/")); } else if (obj.ID_Rol.ToString() == Convert.ToString("2")) { Session["ID"] = obj.ID.ToString(); Session["Nombre"] = obj.Nombre.ToString(); Session["ID_Rol"] = obj.ID_Rol.ToString(); Session["Correo"] = obj.Correo.ToString(); return(View("~/Views/HomeAdmin/Vista.cshtml")); } } } } } } return(View(usermodel)); }
//private void SaveFileToDisk(HttpPostedFileBase file) //{ // WebImage img = new WebImage(file.InputStream); // if (img.Width > 190) // { // img.Resize(190, img.Height); // } // img.Save(Constants.ProductImagePath + file.FileName); // if (img.Width > 100) // { // img.Resize(100, img.Height); // } // img.Save(Constants.ProductThumbnailPath + file.FileName); //} //public Image ResizeImage(int newWidth, int newHeight, string stPhotoPath) //{ // Image imgPhoto = null; // try // { // imgPhoto= Image.FromFile(stPhotoPath); // int sourceWidth = imgPhoto.Width; // int sourceHeight = imgPhoto.Height; // //Consider vertical pics // if (sourceWidth < sourceHeight) // { // int buff = newWidth; // newWidth = newHeight; // newHeight = buff; // } // int sourceX = 0, sourceY = 0, destX = 0, destY = 0; // float nPercent = 0, nPercentW = 0, nPercentH = 0; // nPercentW = ((float)newWidth / (float)sourceWidth); // nPercentH = ((float)newHeight / (float)sourceHeight); // if (nPercentH < nPercentW) // { // nPercent = nPercentH; // destX = System.Convert.ToInt16((newWidth - // (sourceWidth * nPercent)) / 2); // } // else // { // nPercent = nPercentW; // destY = System.Convert.ToInt16((newHeight - // (sourceHeight * nPercent)) / 2); // } // int destWidth = (int)(sourceWidth * nPercent); // int destHeight = (int)(sourceHeight * nPercent); // Bitmap bmPhoto = new Bitmap(newWidth, newHeight, // PixelFormat.Format24bppRgb); // bmPhoto.SetResolution(imgPhoto.HorizontalResolution, // imgPhoto.VerticalResolution); // Graphics grPhoto = Graphics.FromImage(bmPhoto); // grPhoto.Clear(Color.Black); // grPhoto.InterpolationMode = // System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; // grPhoto.DrawImage(imgPhoto, // new Rectangle(destX, destY, destWidth, destHeight), // new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight), // GraphicsUnit.Pixel); // grPhoto.Dispose(); // imgPhoto.Dispose(); // return bmPhoto; // } // catch (FileNotFoundException e) // { // } // return imgPhoto; //} public static List <SelectListItem> GetDropDown() { MeSysEntities db1 = new MeSysEntities(); List <SelectListItem> ls = new List <SelectListItem>(); var lm = db1.Hospital.ToList(); foreach (var temp in lm) { ls.Add(new SelectListItem() { Text = temp.Nombre, Value = temp.ID.ToString() }); } return(ls); }
public SelectList CargarDeportes() { MeSysEntities db1 = new MeSysEntities(); List <SelectListItem> ls = new List <SelectListItem>(); List <Deporte> lm = db1.Deporte.ToList(); foreach (var temp in lm) { ls.Add(new SelectListItem() { Text = temp.Nombre, Value = temp.ID.ToString() }); } SelectList selectLists = new SelectList(ls, "Value", "Text"); return(selectLists); }
public static List <SelectListItem> GetDropDown() { MeSysEntities db1 = new MeSysEntities(); List <SelectListItem> ls = new List <SelectListItem>(); var lm = db1.Roles.ToList(); ls.Add(new SelectListItem { Text = "--Seleccionar Rol--", Value = "0" }); foreach (var temp in lm) { ls.Add(new SelectListItem() { Text = temp.Rol, Value = temp.ID.ToString() }); } return(ls); }
public ActionResult DeleteAtletaCat(int Id) { using (MeSysEntities entities = new MeSysEntities()) { // Employee emp = db.Employee.Where(x => x.EmployeeID == id) if (Id != 0) { Atleta_Categoria atlecat = (from c in entities.Atleta_Categoria where c.ID == Id select c).FirstOrDefault(); entities.Atleta_Categoria.Remove(atlecat); entities.SaveChanges(); } else { return(new EmptyResult()); } } return(new EmptyResult()); }
public async Task <ActionResult> AddCategoryToAthlete(int IdCategoria) { if (IdCategoria <= 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "El ID proporcionado no es válido")); } MeSysEntities db1 = new MeSysEntities(); Categorias categoria = await db1.Categorias.Where(x => x.ID == IdCategoria).FirstOrDefaultAsync(); if (categoria == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "No se encontró ninguna categoria con el ID proporcionado")); } Atleta_Categoria atleta_Categoria = new Atleta_Categoria() { ID_Categoria = IdCategoria, Categorias = categoria }; return(PartialView("/Views/Atleta/_Category.cshtml", atleta_Categoria)); }