public int Create(Marca item) { if (String.IsNullOrEmpty(item.Nome)) { throw new Exception("Atributo Nome é necessario para o registro da Marca."); } else if (item.Id == 0) { throw new Exception("O ID da Marca precisa ser diferente de 0."); } List <Marca> Existentes = Factory.Exist(item); if (Existentes.FirstOrDefault() == null) { return(Factory.Insert(item)); } else { if (Existentes.Where(wh => wh.Id == item.Id).FirstOrDefault() != null) { throw new Exception("ID de Marca já existente no sistema"); } else { throw new Exception("Nome de Marca já existente no sistema"); } } }