public HttpResponseMessage Edit(Guid id, TeacherModel teacherModel)
 {
     var result = new HttpResponseMessage();
     if (ModelState.IsValid)
     {
         var updated = teacherService.Update(id, teacherModel);
         result.StatusCode = HttpStatusCode.OK;
         result.Content = new StringContent(JsonConvert.SerializeObject(updated));
     }
     else
     {
         result.StatusCode = HttpStatusCode.BadRequest;
     }
     return result;
 }
 public IHttpActionResult Create(TeacherModel teacherModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var newGuid = teacherService.Create(teacherModel);
             return Created("api/teachers/" + newGuid, newGuid);
         }
         catch
         {
             return BadRequest();
         }
     }
     return BadRequest();
 }
 public async Task<ActionResult> Edit(Guid id, TeacherModel teacherToUpdate)
 {
         try
         {
             var updated = await PutJsonAsyc(string.Format("api/teachers/{0}", id), teacherToUpdate);
             switch (updated.Type)
             {
                 case ResultType.DbUpdateConcurrencyException:
                     return RedirectToAction("Edit", new {id = teacherToUpdate.Id, concurrencyError = true});
                 case ResultType.DataException:
                     ModelState.AddModelError(string.Empty,
                         "Unable to edit. Try again, and if the problem persists contact your system administrator.");
                     return View(teacherToUpdate);
             }
         }
         catch (RetryLimitExceededException)
         {
             ModelState.AddModelError("",
                 "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
         }
         return RedirectToAction("Details", "Teachers", new { id = teacherToUpdate.Id });
 }
 //[Bind(Include = "IdentityNumber, LastName, FirstMidName, DateOfBirth, Address, EnrollmentDate, EffectiveDate, ExpiryDate, DepartmentId")]
 public async Task<ActionResult> Create(TeacherModel teacher)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var guid = await PostJsonAsyc("api/teachers", teacher);
             return RedirectToAction("Details", new {id = guid});
         }
         return RedirectToAction("BadRequest", "Error");
     }
     catch (RetryLimitExceededException)
     {
         ModelState.AddModelError("",
             "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return View(teacher);
 }