public ReturnAction Save(TipoEnderecoModel model, Guid id) { ReturnAction retorno = new ReturnAction(); var sit = db.TipoEndereco.AsNoTracking().Where(w => w.Id == model.Id); if (sit.Any()) { retorno.Mensagens.Add("O indexador do item já está cadastrado."); } else { var obj = new TipoEndereco(id, model.Nome); if (!obj.EhValido()) { foreach (var item in obj.Get) { retorno.Mensagens.Add(item.Value); } } else { db.Entry(obj).State = EntityState.Added; db.SaveChanges(); } } return(retorno); }
public ReturnAction Save(TipoEnderecoModel model, Guid id) { ReturnAction retorno = new ReturnAction(); var sel = new TipoEnderecoSelect(); var area = sel.GetById(model.Id); if (area != null) { var validations = sel.GetByName(model.Nome); if (validations != null && validations.Id != model.Id) { retorno.Mensagens.Add("Nome ja cadastrado na base"); } } else { retorno.Mensagens.Add("Tipo Endereco não encontrada"); } if (retorno.Valido) { area.ChangeEntity(model.Nome, model.Delete); db.Entry(area).State = EntityState.Modified; db.SaveChanges(); } return(retorno); }
public IActionResult SaveTipoEndereco(TipoEnderecoModel model) { if (!ModelState.IsValid) { return(Json(NegativeReturn)); } return(Json(new TipoEnderecoCore().Save(model, UserId))); }
public ReturnAction Save(TipoEnderecoModel model, Guid id) { if (model.Id != 0) { return(new TipoEnderecoUpdate().Save(model, id)); } else { return(new TipoEnderecoInsert().Save(model, id)); } }
public IActionResult DelTipoEndereco(int id) { var model = new TipoEnderecoModel(); var obj = new TipoEnderecoSelect().GetById(id); if (obj != null) { model.Id = obj.Id; model.Nome = obj.Nome; } return(PartialView("TipoEndereco/Partials/_DelPartial", model)); }