Ejemplo n.º 1
0
        public IHttpActionResult PutTv(int id, Tv tv)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tv.Id)
            {
                return(BadRequest());
            }
            db.Entry(tv).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TvExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
 public void Edit(ElectrDevice device)
 {
     dbDevices.Entry(device).State = EntityState.Modified;
     dbDevices.SaveChanges();
 }
Ejemplo n.º 3
0
        public ActionResult Create(string parametr)
        {
            switch (parametr)
            {
            case "Illuminator":
                db.Illuminators.Add(new Illuminator(BrightnesMode.None, false, "/Content/Images/off-lamp.png"));
                break;

            case "Alarm":
                db.Alarms.Add(new Alarm(AlarmMode.Expectation, false, "/Content/Images/alarm-off.png"));
                break;

            case "Fridge":
                db.Fridges.Add(new Fridge(4, new DeepFreeze(-24, false), false, "/Content/Images/fridge-close.png"));
                break;

            case "Microwave":
                db.Microwaves.Add(new Microwave(160, false, false, "/Content/Images/icon/micrrocloseoff.png"));
                break;
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }