Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="respondentModel"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public async Task <bool> UpdateRespondent(SurveyRespondentViewModel respondentModel, ApplicationUser user)
        {
            if (respondentModel.Id >= 0)
            {
                var respondent = await this._unitOfWork.SurveyRespondents.GetSubRespondentAsync(respondentModel.Id);

                if (respondent == null)
                {
                    return(false);
                }

                respondent.Relationship = respondentModel.Relationship;
                respondent.Name         = respondentModel.Name;

                return(true);
            }
            else if (respondentModel.Id == -1)
            {
                var primary = await this._unitOfWork.SurveyRespondents.GetPrimaryRespondentForUserAsync(user);

                primary.Name = respondentModel.Name;


                return(true);
            }


            return(false);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> UpdateSurveyGroupMember([FromBody] SurveyRespondentViewModel respondent)
        {
            var user = await _userManager.FindByNameAsync(this.User.Identity.Name);

            //var model = AutoMapper.Mapper.Map<SubRespondent>(respondent);
            //var group = await this._respondentGroupService.GetSurveyRespondentGroupForUser(user);
            var result = await this._respondentGroupService.UpdateRespondent(respondent, user);

            await this._unitOfWork.SaveChangesAsync();

            return(new OkResult());
        }