public ActionResult modalFormCadastro(int?id) { var ViewModel = new ProfissaoForm(); ViewModel.OProfissao = this.OProfissaoConsultaBL.carregar(id.toInt()) ?? new Profissao(); return(View(ViewModel)); }
public bool Save(ProfissaoForm entity) { if (entity.IdProfissao == 0) { return(Insert(entity)); } return(Update(entity)); }
private bool Insert(ProfissaoForm model) { using (var context = new DatabaseContext()) { var entity = new Profissao(); entity.DataHoraCadastro = CurrentDateTime; entity.DataHoraAlteracao = CurrentDateTime; entity.IdUsuarioCadastro = IdUsuarioLogado; entity.IdUsuarioAlteracao = IdUsuarioLogado; entity.Status = (int)DefaultStatusEnum.Ativo; entity.Nome = model.Nome; context.Set <Profissao>().Add(entity); RegistrarLogAtividade(context, entity, PERMISSAO_CADASTRO); return(context.SaveChanges() > 0); } }
public ActionResult salvarEvento(ProfissaoForm ViewModel) { if (!ModelState.IsValid) { return(PartialView("modal-form-cadastro", ViewModel)); } bool flagSucesso = this.OProfissaoCadastroBL.salvar(ViewModel.OProfissao); if (flagSucesso) { //this.Flash(UtilMessage.TYPE_MESSAGE_SUCCESS, "O processo de avaliação foi salvo com sucesso."); return(Json(new { error = false, message = "" })); } this.Flash(UtilMessage.TYPE_MESSAGE_ERROR, "Houver algum problema ao tentar salvar os dados do evento."); return(PartialView("modal-form-cadastro", ViewModel)); }
private bool Update(ProfissaoForm model) { using (var context = new DatabaseContext()) { var entity = GetByKeyFull(model.IdProfissao); if (entity == null) { throw new BusinessException("Profissão não encontrada"); } context.Entry(entity).State = EntityState.Modified; entity.DataHoraAlteracao = CurrentDateTime; entity.IdUsuarioAlteracao = IdUsuarioLogado; entity.Status = model.Status; entity.Nome = model.Nome; RegistrarLogAtividade(context, entity, PERMISSAO_ALTERACAO); return(context.SaveChanges() > 0); } }