Beispiel #1
0
        public IActionResult Put(int id, [FromBody] HCPDoctorViewModel hCPDoctorViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Get the HCPDoctor to Edit
            var _hCPDoctor = _unitOfWork.HCPDoctors
                             .GetSingle(id);

            if (_hCPDoctor == null)
            {
                return(NotFound());
            }
            else
            {
                _hCPDoctor.HCPEmployeeId = hCPDoctorViewModel.HCPEmployeeId;

                // Put logic to handle inputer, maker, checker
            }
            hCPDoctorViewModel = _mapper.Map <HCPDoctor, HCPDoctorViewModel>(_hCPDoctor);

            return(new NoContentResult());
        }
Beispiel #2
0
        public IActionResult Post([FromBody] HCPDoctorViewModel hCPDoctorView)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Create the HCPDoctor
            var newHCPDoctor = _mapper.Map <HCPDoctorViewModel, HCPDoctor>(hCPDoctorView);

            _unitOfWork.HCPDoctors.Add(newHCPDoctor);
            // Commit changes to the database to get HCPDoctorId
            _unitOfWork.SaveChanges();

            CreatedAtRouteResult result = CreatedAtRoute("Get", new { controller = "HCPDoctors", id = newHCPDoctor.Id }, newHCPDoctor);

            return(result);
        }