public static void DeletetDB(TipoPrecioModelo modelo) { try { using (efooddatabaseEntities db = new efooddatabaseEntities()) { var datos = (from valor in db.PriceTypes where valor.PriceTypeCode == modelo.PriceTypeCode select valor).SingleOrDefault(); db.PriceTypes.Remove(datos); db.SaveChanges(); BitacoraModel.AddLogBook("n", "Borrar", Admin.ObtenerIdUsuario()); } } catch (Exception x) { ErrorLogModel.AddError(x); } }
public static void AddDB(TipoPrecioModelo modelo) { using (efooddatabaseEntities db = new efooddatabaseEntities()) { try { //Entidades de la base de datos PriceType priceType = new PriceType { PriceTypeCode = ConsecutivoModel.GetConsecutivo("Precios"), PriceTypeDescription = modelo.PriceTypeDescription }; db.PriceTypes.Add(priceType); db.SaveChanges(); BitacoraModel.AddLogBook("a", "Anadir", Admin.ObtenerIdUsuario()); } catch (Exception e) { ErrorLogModel.AddError(e); } } }