コード例 #1
0
        public bool Update(Model.Mascota model)
        {
            bool success = false;

            if (model == null)
            {
                return(false);
            }

            try
            {
                using (var ctx = new PetZooContext())
                {
                    ctx.Mascota.Attach(model);
                    ctx.Entry(model).State = EntityState.Modified;
                    success = ctx.SaveChanges() > 0;
                }
            }
            catch (Exception)
            {
                //log
            }

            return(success);
        }
コード例 #2
0
        public long Add(Model.Mascota model)
        {
            if (model == null)
            {
                return(0);
            }

            try
            {
                using (var ctx = new PetZooContext())
                {
                    ctx.Mascota.Add(model);
                    ctx.SaveChanges();
                }
            }
            catch (Exception)
            {
                //log
            }

            return(model.IdMascota);
        }