public async Task <IHttpActionResult> Create(Gasto model) { var result = new AjaxResult(); try { Controllers.Seguridad.Seguridad seguridad = new Controllers.Seguridad.Seguridad(); model.GastoId = seguridad.generaConsecutivo("Gastos"); model.GastoLinea = 1; model.GastoFecha = DateTime.Today; model.GastoFechaMod = DateTime.Today; model.GastoValor = Decimal.Parse(model.GastoValor.ToString().Replace(".", ",")); if (ModelState.IsValid) { db.Gasto.Add(model); await db.SaveChangesAsync(); AddLog("", model.GastoId, model); return(Ok(result.True("Record saved"))); } else { //return InternalServerError(new Exception("Error, All field are required")); string s = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage)); return(Ok(result.False(s))); } } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <ActionResult> Create(Cliente model) { if (ModelState.IsValid) { var clienteTemp = db.Clientes.Where(c => c.ClienteID == model.ClienteID).FirstOrDefault(); if (clienteTemp == null) { db.Clientes.Add(model); await db.SaveChangesAsync(); AddLog("", model.ClienteID, model); return(RedirectToAction("Index", GetReturnSearch())); } else { ModelState.AddModelError("", "Error, The Client already exists."); } } ViewData["ColeccionPIVId"] = new SelectList(await db.ColeccionPIV.Select(c => new { c.Id, c.Nombre }).ToListAsync(), "Id", "Nombre"); ViewData["VendedorId"] = new SelectList(await db.Usuarios.Select(u => new { u.UsuarioId, u.UsuarioNombre }).ToListAsync(), "UsuarioId", "UsuarioNombre"); ViewData["CanalID"] = new SelectList(await db.Canales.Select(c => new { c.CanalID, c.CanalDesc }).ToListAsync(), "CanalID", "CanalDesc"); ViewData["CiudadID"] = new SelectList(await db.Ciudad.Select(c => new { c.CiudadID, c.CiudadDesc }).ToListAsync(), "CiudadID", "CiudadDesc"); ViewData["DepartamentoID"] = new SelectList(await db.Departamento.Select(d => new { d.DepartamentoID, d.DepartamentoDesc }).ToListAsync(), "DepartamentoID", "DepartamentoDesc"); ViewData["PaisID"] = new SelectList(await db.Pais.Select(p => new { p.PaisID, p.PaisDesc }).ToListAsync(), "PaisID", "PaisDesc"); return(View(model)); }
public async Task <IHttpActionResult> Create(TipoMovimiento tipoMovimiento) { try { var result = new AjaxResult(); var tipoMovTemp = await db.TipoActividades.Where(u => u.TipoActividadID == tipoMovimiento.TipoMovimientoID).FirstOrDefaultAsync(); if (tipoMovTemp == null) { db.TipoMovimientos.Add(tipoMovimiento); await db.SaveChangesAsync(); AddLog("", tipoMovimiento.TipoMovimientoID, tipoMovimiento); } else { return(Ok(result.False("Type of movements already exists"))); } return(Ok(result.True())); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IHttpActionResult> _ResetPassword(ResetPassword reset) { if (ModelState.IsValid) { try { Usuario usuario = db.Usuarios .Include(u => u.UsuarioTokensList) .Where(u => u.UsuarioId == reset.Usuario) .FirstOrDefault(); usuario.Usuariopassword = Fn.EncryptText(reset.Password1); db.UsuarioToken.RemoveRange(usuario.UsuarioTokensList); db.Entry(usuario).State = EntityState.Modified; await db.SaveChangesAsync(); AddLog("Usuarios/_ResetPassword", usuario.UsuarioId, usuario); } catch (Exception e) { return(InternalServerError(e)); } } else { // ViewBag.flag = false; return(Ok(false)); } return(Ok(true)); }
public async Task <ActionResult> Create(Recruitment model) { if (ModelState.IsValid) { model.Estado = EstadoFormatoPQRS.Open; model.CreationDate = DateTime.Now; db.Recruitments.Add(model); await db.SaveChangesAsync(); AddLog("", model.RecruitmentId, model); return(RedirectToAction("Index", GetReturnSearch())); } ViewBag.UsuarioIdSubstitute = new SelectList(db.Usuarios, "UsuarioId", "UsuarioNombre", model.UsuarioIdSubstitute); ViewBag.AreaManagerID = new SelectList(db.Usuarios, "UsuarioId", "UsuarioNombre", model.AreaManagerID); ViewBag.HumanResourcesID = new SelectList(db.Usuarios, "UsuarioId", "UsuarioNombre", model.HumanResourcesID); ViewBag.ImmediateBossID = new SelectList(db.Usuarios, "UsuarioId", "UsuarioNombre", model.ImmediateBossID); ViewBag.CentroCostoID = new SelectList(db.CentroCostos, "CentroCostoID", "CentroCostoDesc", model.CentroCostoID); ViewBag.ProposedCostCenterID = new SelectList(db.CentroCostos, "CentroCostoID", "CentroCostoDesc", model.ProposedCostCenterID); ViewBag.DepartmentId = new SelectList(db.Area, "Id", "Nombre", model.DepartmentId); ViewBag.ProposedDepartmentId = new SelectList(db.Area, "Id", "Nombre", model.ProposedDepartmentId); var sectors = from Sectors d in Enum.GetValues(typeof(Sectors)) select new { ID = (int)d, Name = d.ToString() }; var positions = from Positions d in Enum.GetValues(typeof(Positions)) select new { ID = (int)d, Name = d.ToString() }; var contractTypes = from ContractTypes d in Enum.GetValues(typeof(ContractTypes)) select new { ID = (int)d, Name = d.ToString() }; var budgets = from Budgets d in Enum.GetValues(typeof(Budgets)) select new { ID = (int)d, Name = d.ToString() }; var resignationReasons = from ResignationReasons d in Enum.GetValues(typeof(ResignationReasons)) select new { ID = (int)d, Name = d.ToString() }; var previousNotices = from PreviousNotices d in Enum.GetValues(typeof(PreviousNotices)) select new { ID = (int)d, Name = d.ToString() }; var experienceTimes = from ExperienceTimes d in Enum.GetValues(typeof(ExperienceTimes)) select new { ID = (int)d, Name = d.ToString() }; ViewBag.Sector = new SelectList(sectors, "ID", "Name", model.Sector); ViewBag.Position = new SelectList(positions, "ID", "Name", model.Position); ViewBag.ContractType = new SelectList(contractTypes, "ID", "Name", model.ContractType); ViewBag.Budget = new SelectList(budgets, "ID", "Name", model.Budget); ViewBag.ResignationReason = new SelectList(resignationReasons, "ID", "Name", model.ResignationReason); ViewBag.PreviousNotice = new SelectList(previousNotices, "ID", "Name", model.PreviousNotice); ViewBag.ExperienceTime = new SelectList(experienceTimes, "ID", "Name", model.ExperienceTime); Seguridadcll seguridadcll = (Seguridadcll)Session["seguridad"]; ViewBag.UsuarioNombre = seguridadcll.Usuario.UsuarioId + " - " + seguridadcll.Usuario.UsuarioNombre; ViewBag.UsuarioId = seguridadcll.Usuario.UsuarioId; ViewBag.MotivoPQRS = await db.MotivosPQRS.Where(m => m.TipoPQRS == TipoPQRS.Recruitment && m.Activo == true).ToListAsync(); return(View(model)); }
public async Task <ActionResult> Create(AplicacionesViewModel model) { if (ModelState.IsValid) { model.Aplicacion.AplicacionObjetos = new List <AplicacionObjeto>(); foreach (var obj in model.Objetos) { if (obj.Seleccionado) { model.Aplicacion.AplicacionObjetos.Add(new AplicacionObjeto() { ObjetoId = obj.ObjetoId }); } } db.Aplicaciones.Add(model.Aplicacion); await db.SaveChangesAsync(); AddLog("", model.Aplicacion.Id, model); return(RedirectToAction("Index", GetReturnSearch())); } return(View(model)); }
public async Task <ActionResult> Create(PeriodoViewModel model) { if (ModelState.IsValid) { if (await db.Periodo.AnyAsync(p => model.Periodo.FechaIni <= p.FechaFin && model.Periodo.FechaFin >= p.FechaIni)) { ModelState.AddModelError("", "Date Range is overlaping with other Period."); } if (!ModelState.Values.Any(ms => ms.Errors.Count > 0)) { if (model.Revisiones != null) { model.Periodo.PeriodoRevisiones = model.Revisiones; } db.Periodo.Add(model.Periodo); await db.SaveChangesAsync(); AddLog("", model.Periodo.Id, model); return(RedirectToAction("Index", GetReturnSearch())); } } if (model.Revisiones == null) { model.Revisiones = new List <PeriodoRevision>(); } return(View(model)); }
public async Task <ActionResult> Create(NivelesAprobacion nivelAprobacion) { if (ModelState.IsValid) { if (await db.NivelesAprobacion.AnyAsync(na => na.CanalID == nivelAprobacion.CanalID && na.PlantaID == nivelAprobacion.PlantaID && na.Orden == nivelAprobacion.Orden)) { ModelState.AddModelError("", "Ya existe un un nivel de aprobación con la misma (Planta, Canal, Orden)"); } if (await db.NivelesAprobacion.AnyAsync(na => na.CanalID == nivelAprobacion.CanalID && na.PlantaID == nivelAprobacion.PlantaID && na.UsuarioId == nivelAprobacion.UsuarioId)) { ModelState.AddModelError("", "Ya existe un un nivel de aprobación con la misma (Planta, Canal, Usuario)"); } if (!ModelState.Values.Any(ms => ms.Errors.Count > 0)) { db.NivelesAprobacion.Add(nivelAprobacion); await db.SaveChangesAsync(); AddLog("", nivelAprobacion.Id, nivelAprobacion); return(RedirectToAction("Index", GetReturnSearch())); } } ViewBag.CanalID = new SelectList(db.Canales.OrderBy(c => c.CanalDesc).ToList(), "CanalID", "CanalDesc", nivelAprobacion.CanalID); ViewBag.PlantaID = new SelectList(db.Plantas.OrderBy(p => p.PlantaDesc).ToList(), "PlantaID", "PlantaDesc", nivelAprobacion.PlantaID); ViewBag.UsuarioId = new SelectList(new List <Usuario>()); return(View(nivelAprobacion)); }
//[Bind(Include = "RolId,RolNombre")] public async Task <ActionResult> Create(RolesViewModel model) { if (ModelState.IsValid) { try { db.Roles.Add(model.Rol); db.SaveChanges(); await db.SaveChangesAsync(); //Objetos foreach (var obj in model.Objetos) { if (obj.Seleccionado) { RolObjeto ao = new RolObjeto(); ao.RolId = model.Rol.RolId; ao.ObjetoId = obj.ObjetoId; ao.RolObjetoActivo = true; db.RolObjeto.Add(ao); } } //Apps foreach (var app in model.Apps) { if (app.Seleccionado) { RolAplicacion ao = new RolAplicacion(); ao.AplicacionId = app.AplicacionId; ao.RolId = model.Rol.RolId; db.RolAplicaciones.Add(ao); } } if (!ModelState.Values.Any(ms => ms.Errors.Count > 0)) { await db.SaveChangesAsync(); AddLog("", model.Rol.RolId, model); return(RedirectToAction("Index", GetReturnSearch())); } //Guarda Objetos al rol // guardaRolObjeto(RolObjetoList, rol.RolId); return(RedirectToAction("Index")); } catch (Exception e) { ViewBag.Error = e.ToString(); } } return(View(new RolesViewModel { Rol = model.Rol, Objetos = model.Objetos, Apps = model.Apps })); }
public async Task <IActionResult> Create([Bind("Id,Name,Data,Status")] Machines machines) { if (ModelState.IsValid) { machines.Id = Guid.NewGuid(); _context.Add(machines); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(machines)); }
public async Task <ActionResult> Create(CoreValue coreValue) { if (ModelState.IsValid) { db.CoreValue.Add(coreValue); await db.SaveChangesAsync(); AddLog("", coreValue.Id, coreValue); return(RedirectToAction("Index", GetReturnSearch())); } return(View(coreValue)); }
public async Task <ActionResult> Create(PlantillaViewModel model) { if (ModelState.IsValid) { model.Plantilla.PlantillaItems = model.PlantillaItems; db.Plantilla.Add(model.Plantilla); await db.SaveChangesAsync(); AddLog("", model.Plantilla.Id, model); return(RedirectToAction("Index", GetReturnSearch())); } return(View(model)); }
public async Task <IHttpActionResult> Create(Producto producto) { try { db.Producto.Add(producto); await db.SaveChangesAsync(); AddLog("", producto.CodigoAutoLog, producto); return(Ok(true)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IHttpActionResult> Create(Pais pais) { try { db.Pais.Add(pais); await db.SaveChangesAsync(); AddLog("", pais.PaisID, pais); return(Ok(true)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IHttpActionResult> Create(TipoVisita model) { try { db.TipoVisitas.Add(model); await db.SaveChangesAsync(); AddLog("", model.Id, model); return(Ok(true)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IHttpActionResult> Create(CentroCosto centroCosto) { try { db.CentroCostos.Add(centroCosto); await db.SaveChangesAsync(); AddLog("", centroCosto.CentroCostoID, centroCosto); return(Ok(true)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IHttpActionResult> Create(Canal canal) { try { db.Canales.Add(canal); await db.SaveChangesAsync(); AddLog("", canal.CanalID, canal); return(Ok(true)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IHttpActionResult> Create(Marca marca) { try { db.Marca.Add(marca); await db.SaveChangesAsync(); AddLog("", marca.Id, marca); return(Ok(true)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <JsonResult> AddComment(AddCommentViewModel model) { if (ModelState.IsValid) { // Crear Comment (primer paso Success) PQRSRecordComentario nPQRSComment = new PQRSRecordComentario(); nPQRSComment.PQRSRecordId = model.PQRSRecordId; nPQRSComment.PQRSRecordOrder = model.PQRSRecordOrder;; nPQRSComment.UsuarioId = Seguridadcll.Usuario.UsuarioId; nPQRSComment.FechaCreacion = DateTime.Now; nPQRSComment.Comentario = model.Comment; nPQRSComment.TipoComentario = TipoComentario.Comment; db.PQRSRecordComentarios.Add(nPQRSComment); await db.SaveChangesAsync(); AddLog("PQRS/AddComment", nPQRSComment.Id, nPQRSComment); if (model.PQRSRecordDocumentos != null) { await SaveDocuments(nPQRSComment.Id, model.PQRSRecordDocumentos); } if (model.Files != null) { await UploadFiles(nPQRSComment.Id, model.Files); } API.PQRSController ApiPQRS = new API.PQRSController(); ApiPQRS.SendNotificationEmailTask(API.PQRSController.TipoNotificacion.Comment, model.TipoComentario, model.TipoPQRS, model.PQRSRecordId, model.PQRSRecordOrder, model.DataId, nPQRSComment.Id, Seguridadcll.Usuario.UsuarioNombre, Seguridadcll.Aplicacion.Link); //await Task.Run(() => ApiPQRS.SendNotificationEmailTask(API.PQRSController.TipoNotificacion.Comment, model.TipoComentario, model.TipoPQRS, model.PQRSRecordId, model.PQRSRecordOrder, model.DataId, nPQRSComment.Id)); } return(Json(true, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Create(ObjetosViewModel model) { if (ModelState.IsValid) { try { var objetoTemp = await db.Objeto.Where(o => o.ObjetoId == model.Objeto.ObjetoId).FirstOrDefaultAsync(); if (objetoTemp == null) { if (!model.Objeto.ObjetoMenu) { model.Objeto.ObjetoIcono = null; model.Objeto.ObjetoIdPadre = null; model.Objeto.ObjetoOrden = null; } db.Objeto.Add(model.Objeto); await db.SaveChangesAsync(); // AddLog("", model.Objeto.ObjetoId, model); if (model.Objeto.ObjetoMenu) { foreach (var app in model.Apps) { if (app.Seleccionado) { AplicacionObjeto ao = new AplicacionObjeto(); ao.AplicacionId = app.AplicacionId; ao.ObjetoId = model.Objeto.ObjetoId; db.AplicacionObjetos.Add(ao); } } } if (!ModelState.Values.Any(ms => ms.Errors.Count > 0)) { await db.SaveChangesAsync(); AddLog("", model.Objeto.ObjetoId, model); return(RedirectToAction("Index", GetReturnSearch())); } } else { ModelState.AddModelError("", "Warning, this object " + model.Objeto.ObjetoId + " already exists"); } } catch (Exception e) { ViewBag.error = e.ToString(); } } //ViewBag.ObjetoIdPadre = new SelectList(db.Objeto.Where(o => o.ObjetoId.StartsWith("__") && o.ObjetoMenu).ToList(), "ObjetoId", "ObjetoDesc", objeto.ObjetoIdPadre); ViewBag.Objeto_ObjetoIdPadre = new SelectList(await db.Objeto.Where(o => o.ObjetoId.StartsWith("__") && o.ObjetoMenu).ToListAsync(), "ObjetoId", "ObjetoDesc", model.Objeto.ObjetoIdPadre); return(View(new ObjetosViewModel { Objeto = model.Objeto, Apps = model.Apps })); }
public async Task <IHttpActionResult> Create(PresupuestoVendedor model) { try { var result = new AjaxResult(); if (ModelState.IsValid) { var presupuesto = await db.PresupuestoVendedor.Where( p => p.PresupuestoVendedorAno == model.PresupuestoVendedorAno && p.PlantaID == model.PlantaID && p.CanalID == model.CanalID && p.CentroCostoID == model.CentroCostoID).FirstOrDefaultAsync(); if (presupuesto == null) { db.PresupuestoVendedor.Add(model); await db.SaveChangesAsync(); AddLog("", model.PlantaID, model); } else { return(Ok(result.False("Warning, This Budget already exists"))); //return InternalServerError(new Exception("Warning, This Budget already exists")); } return(Ok(result.True("Record saved"))); } else { //return InternalServerError(new Exception("Error, All field are required")); string s = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage)); return(Ok(result.False(s))); } } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IHttpActionResult> RolAplicaciones(RolAplicacionViewModel model) { try { if (await DeleteRolAplicaciones(model.rol.RolId)) { foreach (var apps in model.aplicaciones) { if (apps.Seleccionado) { db.RolAplicaciones.Add(new RolAplicacion { RolId = model.rol.RolId, AplicacionId = apps.Id }); } } } await db.SaveChangesAsync(); //Inserta Auditoria Controllers.Seguridad.Seguridad seguridad = new Controllers.Seguridad.Seguridad(); Auditoria auditoria = new Auditoria(); Seguridadcll seguridadcll = (Seguridadcll)HttpContext.Current.Session["seguridad"]; auditoria.AuditoriaFecha = System.DateTime.Now; auditoria.AuditoriaHora = System.DateTime.Now.TimeOfDay; auditoria.usuarioId = seguridadcll.Usuario.UsuarioId; auditoria.AuditoriaEvento = "Add_Apps"; auditoria.AuditoriaDesc = "Add_Apps : " + model.rol.RolId; auditoria.ObjetoId = "Roles/RolAplicaciones"; seguridad.insertAuditoria(auditoria); //Inserta Auditoria return(Ok(true)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <ActionResult> Create(CausaPQRS model) { if (ModelState.IsValid) { if (model.TipoPQRS != 0) { db.CausaPQRS.Add(model); await db.SaveChangesAsync(); AddLog("", model.Id, model); return(RedirectToAction("Index", GetReturnSearch())); } else { ModelState.AddModelError("", "Error, Please select type PQRS"); } } return(View(model)); }
public async Task <IHttpActionResult> CambiarFoto([FromBody] string profilePictureBase64) { try { var usuarioHV = await db.UsuarioHV.FirstOrDefaultAsync(u => u.UsuarioId == Seguridadcll.Usuario.UsuarioId); string[] profilePicture = profilePictureBase64.Split(','); using (var ms = new MemoryStream(Convert.FromBase64String(profilePicture[1]))) { var bitmap = Fn.ResizeBitmap(new System.Drawing.Bitmap(ms), 200, 200); if (usuarioHV == null) { usuarioHV = new UsuarioHV { UsuarioId = Seguridadcll.Usuario.UsuarioId, FotoMediaType = profilePicture[0].Replace("data:", "").Replace(";base64", ""), Foto = Fn.BitmapToByte(bitmap), }; db.UsuarioHV.Add(usuarioHV); } else { usuarioHV.FotoMediaType = profilePicture[0].Replace("data:", "").Replace(";base64", ""); usuarioHV.Foto = Fn.BitmapToByte(bitmap); db.Entry(usuarioHV).State = EntityState.Modified; } } await db.SaveChangesAsync(); AddLog("", usuarioHV.UsuarioId, null); return(Ok(true)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <ActionResult> Create(CategoriaCDE categoria) { if (ModelState.IsValid) { if (await db.CategoriaCDE.AnyAsync(c => c.LiquidacionId == null && categoria.ValorMinimo <= c.ValorMaximo && categoria.ValorMaximo >= c.ValorMinimo)) { ModelState.AddModelError("", "Given values are overlaping with other COE Category values"); } if (!ModelState.Values.Any(ms => ms.Errors.Count > 0)) { db.CategoriaCDE.Add(categoria); await db.SaveChangesAsync(); AddLog("", categoria.Id, categoria); return(RedirectToAction("Index", GetReturnSearch())); } } return(View(categoria)); }
public async Task <ActionResult> Create(Departamento model) { if (ModelState.IsValid) { var dptoTemp = db.Departamento.Where(d => d.DepartamentoID == model.DepartamentoID && d.PaisID == model.PaisID).FirstOrDefault(); if (dptoTemp == null) { db.Departamento.Add(model); await db.SaveChangesAsync(); AddLog("", model.DepartamentoID, model); return(RedirectToAction("Index", GetReturnSearch())); } else { ModelState.AddModelError("", "Error, The Department already exists."); } } return(View(model)); }
public async Task <ActionResult> Create(ReglaViewModel model) { if (ModelState.IsValid) { if (model.Tipo == ReglaViewModel.TipoRegla.Item) { model.Regla.MarcaId = null; } else { model.Regla.ItemId = null; } db.Regla.Add(model.Regla); await db.SaveChangesAsync(); AddLog("", model.Regla.Id, model.Regla); return(RedirectToAction("Index", GetReturnSearch())); } return(View(model)); }
public async Task <ActionResult> Create(Item model) { if (ModelState.IsValid) { var itemTemp = db.Item.Where(i => i.Codigo == model.Codigo).FirstOrDefault(); if (itemTemp == null) { db.Item.Add(model); await db.SaveChangesAsync(); AddLog("", model.Id, model); return(RedirectToAction("Index", GetReturnSearch())); } else { ModelState.AddModelError("", "Error, Code already exists."); } } ViewData["MarcaId"] = new SelectList(await db.Marca.Select(m => new { m.Id, m.Nombre }).ToListAsync(), "Id", "Nombre"); return(View(model)); }
public async Task <IHttpActionResult> Create(Correos model) { try { var result = new AjaxResult(); if (ModelState.IsValid) { var correo = await db.Correos.Where(c => c.Mail.Contains(model.Mail)) .FirstOrDefaultAsync(); if (correo == null) { db.Correos.Add(model); await db.SaveChangesAsync(); AddLog("", model.Id, model); } else { return(Ok(result.False("Warning, This e-Mail already exists"))); //return InternalServerError(new Exception("Warning, This Budget already exists")); } return(Ok(result.True("Record Saved"))); } else { //return InternalServerError(new Exception("Error, All field are required")); string s = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage)); return(Ok(result.False(s))); } } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <ActionResult> Create(Ciudad model) { if (ModelState.IsValid) { var ciudadTemp = db.Ciudad.Where(c => c.CiudadID == model.CiudadID && c.DepartamentoID == model.DepartamentoID && c.PaisID == model.PaisID).FirstOrDefault(); if (ciudadTemp == null) { db.Ciudad.Add(model); await db.SaveChangesAsync(); AddLog("", model.CiudadID, model); return(RedirectToAction("Index", GetReturnSearch())); } else { ModelState.AddModelError("", "Error, The City already exists."); } } ViewData["DepartamentoID"] = new SelectList(await db.Departamento.Select(d => new { d.DepartamentoID, d.DepartamentoDesc }).ToListAsync(), "DepartamentoID", "DepartamentoDesc"); ViewData["PaisID"] = new SelectList(await db.Pais.Select(p => new { p.PaisID, p.PaisDesc }).ToListAsync(), "PaisID", "PaisDesc"); return(View(model)); }