public ActionResult Create(FormCollection collection) { try { Usuario user = (Usuario)Session["usuario"]; Visita visita = new Visita(); if (!string.IsNullOrEmpty(collection["tipoTarefa"])) { visita.TipoTarefa = Convert.ToInt32(collection["tipoTarefa"]); } if (!string.IsNullOrEmpty(collection["tipoCliente1"])) { visita.ClienteBase = Convert.ToInt32(collection["tipoCliente1"]); } if (!string.IsNullOrEmpty(collection["clientes"])) { visita.IDCliente = Convert.ToInt32(collection["clientes"]); } if (!string.IsNullOrEmpty(collection["assunto"])) { visita.Assunto = collection["assunto"]; } if (!string.IsNullOrEmpty(collection["dataInicio"])) { visita.DataInicio = Convert.ToDateTime(collection["dataInicio"]); } if (!string.IsNullOrEmpty(collection["dataConclusao"])) { visita.DataConclusao = Convert.ToDateTime(collection["dataConclusao"]); } if (!string.IsNullOrEmpty(collection["descricao"])) { visita.Descricao = collection["descricao"]; } if (user != null) { visita.IDUsuario = user.Handle; } CRMEntities dbContext = new CRMEntities(); dbContext.AddToVisitas(visita); dbContext.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }
/// <summary> /// Deprecated Method for adding a new object to the Visitas EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToVisitas(Visita visita) { base.AddObject("Visitas", visita); }
/// <summary> /// Create a new Visita object. /// </summary> /// <param name="handle">Initial value of the Handle property.</param> /// <param name="iDUsuario">Initial value of the IDUsuario property.</param> /// <param name="iDCliente">Initial value of the IDCliente property.</param> public static Visita CreateVisita(global::System.Int32 handle, global::System.Int32 iDUsuario, global::System.Int32 iDCliente) { Visita visita = new Visita(); visita.Handle = handle; visita.IDUsuario = iDUsuario; visita.IDCliente = iDCliente; return visita; }