Beispiel #1
0
        public async Task <IActionResult> UpdateDetail(int id, [FromBody] UpdateProfileParam param)
        {
            var model = new UserDetailMediCoreModel
            {
                Id        = id,
                UserId    = _authServices.GetUserId() ?? 0,
                PatientId = param.PatientId.HasValue ? param.PatientId : null,
                FirstName = param.FirstName,
                LastName  = param.LastName,
                Address   = param.Address,
                RegencyId = param.RegencyId
            };

            model.Patient = new PatientModel
            {
                Id                 = param.PatientId ?? 0,
                PatientName        = String.Format("{0} {1}", param.FirstName, param.LastName),
                DateOfBirth        = param.DateOfBirth,
                PatientStatus      = PatientStatus.Active,
                Gender             = param.Gender,
                RelationshipStatus = RelationshipStatus.YourSelf,
                AssociatedUserId   = model.UserId
            };
            var response = await _userDetailService.EditWithPatientAsync(model);

            if (response.Success)
            {
                return(Ok(response.Item));
            }

            return(BadRequest(response.Message));
        }
Beispiel #2
0
        public IActionResult CreateDetail([FromBody] UserDetailMediCoreModel model)
        {
            AssignModelState();
            var response = _userDetailService.Create(model);

            if (response.Success)
            {
                // by default user is patient
                var patientResponse = _patientService.Create(new PatientModel
                {
                    PatientName        = String.Format("{0} {1}", model.FirstName, model.LastName),
                    DateOfBirth        = model.Patient.DateOfBirth,
                    PatientStatus      = PatientStatus.Active,
                    Gender             = model.Patient.Gender,
                    RelationshipStatus = RelationshipStatus.YourSelf,
                    AssociatedUserId   = response.Item.UserId
                });
                if (patientResponse.Success)
                {
                    // Update User Detail
                    var detail = response.Item;
                    detail.PatientId = patientResponse.Item.Id;
                    var userResponse = _userDetailService.Edit(response.Item);
                    if (userResponse.Success)
                    {
                        return(Ok(userResponse.Item));
                    }
                }
            }
            return(BadRequest(response.Message));
        }
Beispiel #3
0
        public IActionResult EditUserDetail(int id, [FromBody] UserDetailMediCoreModel param)
        {
            AssignModelState();
            param.Id     = id;
            param.UserId = _auth.GetUserId() ?? 0;
            var response = _userDetailService.Edit(param);

            if (response.Success)
            {
                return(Ok(response.Item));
            }
            return(BadRequest(response.Message));
        }