Exemplo n.º 1
0
        public async Task <IActionResult> Put(long Id, InstructorDTO instructorDTO)
        {
            var instructor = _mapper.Map <Instructor>(instructorDTO);

            instructor.Id = Id;
            var result = await _instructorService.UpdateInstructor(instructor);

            instructorDTO = _mapper.Map <InstructorDTO>(instructor);
            var response = new APIResponse <InstructorDTO>(instructorDTO);

            return(Ok(response));
        }
Exemplo n.º 2
0
        public ActionResult Edit([Bind(Include = "Id,InstructorName,InstructorContact")] Instructor instructor)
        {
            var validationResult = _instructorService.Validate(instructor);

            if (!validationResult.Item1)
            {
                throw new Exception(validationResult.Item2);
            }

            _instructorService.UpdateInstructor(instructor);

            return(RedirectToAction("Index"));
        }
 public IHttpActionResult Update(InstructorWithCoursesIn instructorWithCoursesIn)
 {
     if (instructorWithCoursesIn == null)
     {
         return(new Helpers.ActionResultBuilder
                .CreateActionResult <InstructorWithCoursesIn>(Request, null, System.Net.HttpStatusCode.BadRequest));
     }
     else
     {
         _instructorService.UpdateInstructor(instructorWithCoursesIn);
         return(new Helpers.ActionResultBuilder
                .CreateActionResult <InstructorWithCoursesIn>(Request, instructorWithCoursesIn, System.Net.HttpStatusCode.OK));
     }
 }
 public IHttpActionResult Update([System.Web.Mvc.Bind(Include = "Id,LastName,FirstName,HireDate,Courses")] InstructorWithCoursesIn instructorWithCoursesIn)
 {
     if (instructorWithCoursesIn == null)
     {
         return(new Helpers.ActionResultBuilder
                .CreateActionResult <InstructorWithCoursesIn>(Request, null, System.Net.HttpStatusCode.BadRequest));
     }
     else
     {
         _instructorService.UpdateInstructor(instructorWithCoursesIn);
         return(new Helpers.ActionResultBuilder
                .CreateActionResult <InstructorWithCoursesIn>(Request, instructorWithCoursesIn, System.Net.HttpStatusCode.OK));
     }
 }
 public IActionResult EditInstructor(Instructor instructor)
 {
     try
     {
         _instructorService.UpdateInstructor(instructor);
         ViewData["Message"] = "Info Updated";
         return(View("Message"));
     }
     catch (Exception e)
     {
         ViewData["Message"] = e.Message;
         return(View("Message"));
     }
 }
        public IActionResult UpdateInstructor([FromBody] InstructorDTO instructorDTO)
        {
            if (instructorDTO == null)
            {
                return(BadRequest("Error"));
            }

            try
            {
                var instructor = _mapper.Map <InstructorDTO, Instructor>(instructorDTO);
                _instructorService.UpdateInstructor(instructor, instructorDTO.Categories);
                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest("Error"));
            }
        }
Exemplo n.º 7
0
 public HttpResponseMessage Put([FromUri] int id, [FromBody] InstructorPerson instructor)
 {
     if (!ModelState.IsValid)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, "Instructor data is invalid."));
     }
     try {
         Instructor ins = _Instructorservice.GetInstructorById(id);
         if (ins == null)
         {
             return(Request.CreateResponse(HttpStatusCode.NotFound, "Instructor with Id " + id.ToString() + " not found to update"));
         }
         _Instructorservice.UpdateInstructor(instructor);
         return(Request.CreateResponse(HttpStatusCode.OK, instructor));
     }
     catch (Exception ex) {// should log ex ourselves, should not return to the user
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Some internal error occurs..."));
     }
 }
Exemplo n.º 8
0
 public HttpResponseMessage Put(Instructor instructor)
 {
     _instructorService.UpdateInstructor(instructor);
     return(Request.CreateResponse(HttpStatusCode.OK, instructor));
 }
Exemplo n.º 9
0
 public ActionResult Update(Instructor instructor)
 {
     _service.UpdateInstructor(instructor);
     return(View("Detail", instructor.Id));
 }