public bool SavePetLocation(RegistroAnimalViewModel registroViewModel) { try { using (animalsDataModel.Model.SaveAPetEntities edmx = new animalsDataModel.Model.SaveAPetEntities()) { animalsDataModel.Model.RegistroAnimal registroEntity = AutoMapper.Mapper.Map<animalsDataModel.Model.RegistroAnimal>(registroViewModel); edmx.RegistroAnimal.Add(registroEntity); edmx.SaveChanges(); } return true; } catch (Exception ex) { Console.WriteLine(ex.Message); return false; } }
public bool UpdatePetLocation(RegistroAnimalViewModel registroViewModel) { try { using (animalsDataModel.Model.SaveAPetEntities edmx = new animalsDataModel.Model.SaveAPetEntities()) { animalsDataModel.Model.RegistroAnimal tag = edmx.RegistroAnimal.FirstOrDefault(o => o.IdRegistroAnimal == registroViewModel.IdRegistroAnimal); if (tag == null) return false; tag.Descricao = registroViewModel.Descricao; tag.IdEstadoAnimal = registroViewModel.IdEstadoAnimal; tag.IdSituacaoAnimal = registroViewModel.IdSituacaoAnimal; tag.Latitude = (decimal)registroViewModel.Latitude; tag.Longitude = (decimal)registroViewModel.Longitude; edmx.SaveChanges(); } return true; } catch (Exception ex) { return false; } }