/// <summary> /// Altera dados na base de dados /// </summary> /// <param name="responsavel"></param> public void Editar(ResponsavelModel responsavel) { tb_responsavel responsavelE = new tb_responsavel(); Atribuir(responsavel, responsavelE); unitOfWork.RepositorioResponsavel.Editar(responsavelE); unitOfWork.Commit(shared); }
/// <summary> /// Insere um novo na base de dados /// </summary> /// <param name="responsavel">Dados do modelo</param> /// <returns>Chave identificante na base</returns> public int Inserir(ResponsavelModel responsavel) { tb_responsavel responsavelE = new tb_responsavel(); Atribuir(responsavel, responsavelE); unitOfWork.RepositorioResponsavel.Inserir(responsavelE); unitOfWork.Commit(shared); return responsavelE.id_Responsavel; }
public ActionResult Create(ResponsavelModel responsavel) { if (ModelState.IsValid) { MembershipUser usuario = Membership.GetUser(); int idCodigo = retornarIdResponsavel(usuario.ToString()); if (idCodigo != -1) { Roles.AddUserToRole(usuario.ToString(), "Responsavel"); responsavel.id_Responsavel = idCodigo; gResponsavel.Inserir(responsavel); return RedirectToAction("Index"); } return RedirectToAction("Index"); } return View(); }
/// <summary> /// Atribui dados da responsavel Model para a responsavel Entity /// </summary> /// <param name="responsavel">Objeto do modelo</param> /// <param name="esp">Entity mapeada da base de dados</param> private void Atribuir(ResponsavelModel responsavel, tb_responsavel responsavelE) { responsavelE.id_Responsavel = responsavel.id_Responsavel; responsavelE.nome = responsavel.nome; responsavelE.sobrenome = responsavel.sobrenome; responsavelE.email = responsavel.email; }
public ActionResult Edit(int id, ResponsavelModel responsavelModel) { // TODO: Add update logic here if (ModelState.IsValid) { gResponsavel.Editar(responsavelModel); return RedirectToAction("Index"); } return View(responsavelModel); }
public ActionResult Delete(int id, ResponsavelModel responsavelModel) { if (ModelState.IsValid) { gResponsavel.Remover(id); return RedirectToAction("Index"); } return View(responsavelModel); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user MembershipCreateStatus createStatus; Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); ResponsavelModel responsavel = new ResponsavelModel(); responsavel.nome = model.UserName; responsavel.email = model.Email; responsavel.sobrenome = model.UserName; gResponsavel.Inserir(responsavel); //Membership usuario = Membership.GetUser(); Roles.AddUserToRole(model.UserName, "Responsavel"); if (createStatus == MembershipCreateStatus.Success) { FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */); return RedirectToAction("Index", "Home"); } else { ModelState.AddModelError("", ErrorCodeToString(createStatus)); } } // If we got this far, something failed, redisplay form return View(model); }