public long?Agregar(SalonDto salon) { using (var context = new ModeloXCommerceContainer()) { var salonAgregar = new AccesoDatos.Salon { Descripcion = salon.Descripcion, ListaPrecioId = salon.ListaPreciosId }; context.Salones.Add(salonAgregar); context.SaveChanges(); return(salonAgregar.Id); } }
public void Modificar(SalonDto salon) { using (var context = new ModeloXCommerceContainer()) { var salonMod = context.Salones.FirstOrDefault(x => x.Id == salon.Id); if (salonMod == null) { throw new Exception("No se encontro el Salon"); } salonMod.Descripcion = salon.Descripcion; salonMod.EstaEliminado = salon.EstaEliminado; salonMod.Id = salon.Id; salonMod.ListaPrecioId = salon.ListaPreciosId; context.SaveChanges(); } }
public long Insertar(SalonDto salonDto) { using (var context = new ModeloXCommerceContainer()) { var salonNuevo = new AccesoDatos.Salon { EstaEliminado = salonDto.EstaEliminado, Descripcion = salonDto.Descripcion, ListaPrecioId = salonDto.ListaPrecioId }; context.Salones.Add(salonNuevo); context.SaveChanges(); return(salonNuevo.Id); } }
public override bool EjecutarComandoNuevo() { if (!VerificarDatosObligatorios()) { MessageBox.Show(@"Por favor ingrese los campos Obligatorios.", @"Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } var nuevoSalon = new SalonDto { Descripcion = txtDescripcion.Text, ListaPrecioId = ((ListaPrecioDto)cmbListaPrecioSalon.SelectedItem).Id }; _salonServicio.Insertar(nuevoSalon); return(true); }
public override bool EjecutarComandoModificar() { if (!VerificarDatosObligatorios()) { MessageBox.Show(@"Por favor ingrese los campos Obligatorios.", @"Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } var provinciaParaModificar = new SalonDto { Id = EntidadId.Value, Descripcion = txtDescripcion.Text }; _salonServicio.Modificar(provinciaParaModificar); return(true); }
public void Modificar(SalonDto salonDto) { using (var context = new ModeloXCommerceContainer()) { var salonModificar = context.Salones .FirstOrDefault(x => x.Id == salonDto.Id); if (salonModificar == null) { throw new Exception("Ocurrio un error al Obtener el Salón"); } salonModificar.Descripcion = salonDto.Descripcion; salonModificar.EstaEliminado = salonDto.EstaEliminado; context.SaveChanges(); } }
public override bool EjecutarComandoModificar() { if (!VerificarDatosObligatorios()) { MessageBox.Show(@"Por favor ingrese los campos Obligatorios.", @"Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } var salonParaModificar = new SalonDto { Id = EntidadId.Value, Descripcion = txtDescripcion.Text, ListaPreciosId = ((ListaPreciosDto)cmbLista.SelectedItem).Id }; _salonServicio.Modificar(salonParaModificar); return(true); }
public void AddObjectRefersToExistingEntityObjectId() { Seed(Context); var city = Context.Cities.First(); var country = Context.Countries.First(); var salon = new SalonDto() { Name = "salon1", Description = "some des", CountryId = 1, CityId = 1, }; var service = new Repository <SalonDto>(Context); service.Add(salon); var obj = Context.Salons.Find(salon.Id); Assert.NotNull(obj); }
public void RemoveCascadeDeleteShouldFail() { Seed(Context); var city = Context.Cities.First(); var country = Context.Countries.First(); var salon = new SalonDto() { Name = "salon1", Description = "some des", CountryDto = country, CityDto = city, }; Context.Salons.Add(salon); Context.SaveChanges(); var countCities = Context.Cities.Count(); var countSalons = Context.Salons.Count(); var service = new Repository <CityDto>(Context); Assert.ThrowsAny <Exception>(() => service.Remove(city)); }