public async Task <bool> SaveUserDancingAsync(DancingModel dancingModel) { if (dancingModel != null) { var userDancing = new UserDancing { Id = dancingModel.Id, UserId = UserContext.Current.UserId, ChoreographyAbilitiesCode = dancingModel.ChoreographyAbilities, AgentNeedCode = dancingModel.AgentNeed, Experiance = dancingModel.Experience, DanceAbilitiesCode = dancingModel.DanceAbilities, IsAttendedSchool = dancingModel.IsAttendedSchool, IsAgent = dancingModel.IsAgent, IsActive = true, IsDeleted = false }; var danceStyleIds = new ConcurrentBag <long>(); if (dancingModel.DnacingStyles != null && dancingModel.DnacingStyles.Any()) { dancingModel.DnacingStyles.AsParallel().ForAll(x => { if (x.SelectedValue != 0) { danceStyleIds.Add(x.SelectedValue ?? 0); } }); } return(await _userDancingRepository.PerformSaveAndUpdateOperationAsync(userDancing, danceStyleIds)); } return(false); }
public virtual async Task <DancingModel> FetchUserDancingAsync(Guid userId) { var dancingModel = new DancingModel() { AgentNeed = 0, DanceAbilities = 0, ChoreographyAbilities = 0, DanceAbilitiesText = ExpertLavel.Beginner.ToString(), ChoreographyAbilitiesText = ExpertLavel.Beginner.ToString(), HasDanceStyle = false, DnacingStyles = new List <DancingStyleDto>() }; var userDancing = await _userDancingRepository.GetUserDancingAsync(userId); var dancingStyle = await _userDancingRepository.GetDancingStyleSelectedAsync(userId); if (userDancing.IsNotNull()) { dancingModel = new DancingModel { Id = userDancing.Id, AgentNeed = userDancing.AgentNeedCode ?? 0, DanceAbilities = userDancing.DanceAbilitiesCode, ChoreographyAbilities = userDancing.ChoreographyAbilitiesCode, DanceAbilitiesText = ((ExpertLavel)userDancing.DanceAbilitiesCode).ToString(), ChoreographyAbilitiesText = ((ExpertLavel)userDancing.ChoreographyAbilitiesCode).ToString(), IsAgent = userDancing.IsAgent, IsAttendedSchool = userDancing.IsAttendedSchool, Experience = userDancing.Experiance, UserId = userDancing.UserId, DnacingStyles = new List <DancingStyleDto>() }; } if (dancingStyle.IsNotNull()) { var danceStyle = dancingStyle.Select(x => { return(new DancingStyleDto { Id = x.Id, Name = x.Style, SelectedValue = x.SelectedValue, Value = x.Value }); }); danceStyle.ToList().ForEach(x => dancingModel.DnacingStyles.Add(x)); dancingModel.HasDanceStyle = dancingModel.DnacingStyles.Any(x => (x.SelectedValue ?? 0) > 0); } return(dancingModel); }
public async Task <IActionResult> SaveUserDancing([FromBody] DancingModel dancingModel) { if (dancingModel.IsNull()) { return(BadRequest(HttpStatusText.InvalidRequest)); } var isSuccess = await _profileEditManager.SaveUserDancingAsync(dancingModel); if (isSuccess) { return(Ok(isSuccess)); } return(StatusCode(StatusCodes.Status304NotModified, this)); }
public async Task <IActionResult> SaveUserDancing([FromBody] DancingModel dancingModel) { if (dancingModel.IsNull()) { return(BadRequest(new MessageResult { Message = ErrorMessage.BadRequest, Code = StatusCodes.Status400BadRequest })); } var isSuccess = await _profileEditManager.SaveUserDancingAsync(dancingModel); if (isSuccess) { return(Ok(isSuccess)); } return(StatusCode(StatusCodes.Status304NotModified, this)); }