public async Task <ActionResult> Create([Bind(Include = "EventId,PersonalId,Name,Description,EventDate,IsPrivate,DateCreated,Status,IsDeleted")] Event @event) { if (ModelState.IsValid) { @event.EventId = Guid.NewGuid(); db.Event.Add(@event); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.PersonalId = new SelectList(db.Personal, "PersonalId", "Name", @event.PersonalId); return(View(@event)); }
public async Task <ActionResult> Create([Bind(Include = "PersonalId,Name,LastName,Email,IsDeleted,Phone")] Personal personal) { if (ModelState.IsValid) { if (string.IsNullOrEmpty(personal.Name) && string.IsNullOrEmpty(personal.LastName)) { ModelState.AddModelError("", "El Nombre y el apellido son requeridos"); return(View(personal)); } personal.PersonalId = Guid.NewGuid(); db.Personal.Add(personal); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(personal)); }