private void InsertOrUpdateDeviceStudent(List <Device> devices, Student student) { // can only be one device atm, so hardcoding it... Device newDevice = devices[0]; try { Device d = db.devices.First(x => x.id.Equals(newDevice.id)); if (d != null) { d.Student = student; d.deviceType = newDevice.deviceType; d.token = newDevice.token; db.Entry(d).State = EntityState.Modified; db.SaveChanges(); } else { newDevice.Student = student; db.devices.Add(newDevice); db.SaveChanges(); } } catch { newDevice.Student = student; db.devices.Add(newDevice); db.SaveChanges(); } }
public async Task <IHttpActionResult> PutProject(string id, Project project) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != project.uuid) { return(BadRequest()); } db.Entry(project).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PutApprovedCourse(string id, ApprovedCourse approvedCourse) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != approvedCourse.id) { return(BadRequest()); } db.Entry(approvedCourse).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ApprovedCourseExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "id,name,adress,url,facebook,linkedIn,description,logo")] Company company) { if (ModelState.IsValid) { db.Entry(company).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(company)); }
public async Task <ActionResult> Edit([Bind(Include = "id,name")] Location location) { if (ModelState.IsValid) { db.Entry(location).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(location)); }
public async Task <ActionResult> Edit([Bind(Include = "id,name,position,phone,email")] Contact contact) { if (ModelState.IsValid) { db.Entry(contact).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(contact)); }
public async Task <ActionResult> Edit([Bind(Include = "id,token,deviceType")] Device device) { if (ModelState.IsValid) { db.Entry(device).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(device)); }
public async Task <ActionResult> Edit([Bind(Include = "username,name,email")] Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(student)); }
public async Task <ActionResult> Edit([Bind(Include = "uuid,title,description,webpage,linkedInProfile,expiryDate,stepsToApply,created,published,modified")] Job job) { if (ModelState.IsValid) { db.Entry(job).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(job)); }