public HttpResponseMessage Put(int id, [FromBody] TeacherViewModel teacherViewModel)
        {
            try
            {
                var userId    = this.User.FindFirstValue(ClaimTypes.Name);
                var tempUsers = AutoMapper.Mapper.Map <Users>(teacherViewModel);
                tempUsers.CreatedDate = DateTime.Now;
                tempUsers.Createdby   = Convert.ToInt32(userId);
                tempUsers.Password    = EncryptLib.EncryptText(teacherViewModel.Password);
                _users.UpdateUsers(tempUsers);
                var tempTeacher = AutoMapper.Mapper.Map <Teacher>(teacherViewModel);
                _teacher.UpdateTeacher(tempTeacher);
                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK
                };

                return(response);
            }
            catch (Exception)
            {
                var response = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.InternalServerError
                };
                return(response);
            }
        }
Пример #2
0
 public void Edit([FromBody] Teacher teacher)
 {
     if (ModelState.IsValid)
     {
         objteacher.UpdateTeacher(teacher);
     }
 }
Пример #3
0
 public IActionResult Edit(Teacher teacher)
 {
     if (ModelState.IsValid)
     {
         teacherService.UpdateTeacher(teacher);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(teacher));
 }
Пример #4
0
        public IActionResult UpdateTeacher(int Id, [FromBody] Teacher teacherObject)
        {
            if (Id < 0)
            {
                BadRequest();
            }

            int result = _teacherRepo.UpdateTeacher(Id, teacherObject);

            if (result == 0)
            {
                return(BadRequest());
            }
            return(Ok());
        }