public ActionResult Create([Bind(Include = "RaspiId,UserId,Pin1,Pin2,Pin3")] Raspi raspi) { if (ModelState.IsValid) { db.Raspis.Add(raspi); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(raspi)); }
public async Task <ActionResult> PersonalAccount(UserAccountViewModel model, int userId, int raspiId, bool pin1, bool pin2, bool pin3) { if (ModelState.IsValid) { Raspi raspi = new Raspi() { Pin1 = pin1, Pin2 = pin2, Pin3 = pin3, RaspiId = raspiId }; sensorData.Raspis.Attach(raspi); sensorData.Entry(raspi).Property(x => x.Pin1).IsModified = true; sensorData.Entry(raspi).Property(x => x.Pin2).IsModified = true; sensorData.Entry(raspi).Property(x => x.Pin3).IsModified = true; sensorData.SaveChanges(); User myUser = sensorData.Users.FirstOrDefault(u => u.Id == userId); model = new UserAccountViewModel(myUser); return(View(model)); } return(View(model)); }