public HttpResponseMessage Edit(Guid id, StudentModel studentModel)
 {
     var result = new HttpResponseMessage();
     if (ModelState.IsValid)
     {
         var updated = studentService.Update(id, studentModel);
         result.StatusCode = HttpStatusCode.OK;
         result.Content = new StringContent(JsonConvert.SerializeObject(updated));
     }
     else
     {
         result.StatusCode = HttpStatusCode.BadRequest;
     }
     return result;
 }
 public IHttpActionResult Create(StudentModel studentModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var newGuid = studentService.Create(studentModel);
             return Created("api/students/" + newGuid, newGuid);
         }
         catch(Exception ex)
         {
             return BadRequest();
         }
     }
     return BadRequest();
 }
 public async Task<ActionResult> Edit(Guid id, StudentModel studentToUpdate)
 {
     try
     {
         var updated = await PutJsonAsyc(string.Format("api/students/{0}", id), studentToUpdate);
         switch (updated.Type)
         {
             case ResultType.DbUpdateConcurrencyException:
                 return RedirectToAction("Edit", new {id = studentToUpdate.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(studentToUpdate);
         }
     }
     catch (RetryLimitExceededException)
     {
         ModelState.AddModelError("",
             "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
     }
     return RedirectToAction("Details", "Students", new {id = studentToUpdate.Id});
 }
 //[Bind(Include = "IdentityNumber, LastName, FirstMidName, DateOfBirth, Address, EnrollmentDate, EffectiveDate, ExpiryDate, DepartmentId")]
 public async Task<ActionResult> Create(StudentModel student)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var guid = await PostJsonAsyc("api/students", student);
             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(student);
 }