public bool AcceptStatusLocationSuggestion(int suggestionId) { try { LocationSuggestion suggest = _locationSuggestionRepository.Get(_ => _.Id == suggestionId, _ => _.Locations); suggest.Status = RequestStatus.Approved; _locationSuggestionRepository.Update(suggest); ICollection <Location> locations = new List <Location>(); var plan = _planRepository.Get(_ => _.Id == suggest.PlanId, _ => _.PlanLocations); foreach (var item in suggest.Locations) { _planLocationRepository.Create(new PlanLocation { PlanId = suggest.PlanId, LocationId = item.Id, Done = false, PlanDay = suggest.PlanDay ?? 0 }); } _unitOfWork.SaveChanges(); return(true); } catch (Exception ex) { _loggingService.Write(GetType().Name, nameof(AcceptStatusLocationSuggestion), ex); return(false); } }
public async Task <IHttpActionResult> AddSuggestionToPlan(LocationSuggestionViewModels locationSuggestion) { try { int userId = (await CurrentUser()).Id; ICollection <Location> locations = new List <Location>(); foreach (var item in locationSuggestion.LocationIds ?? new List <int>()) { var location = _locationService.Find(item); if (location != null) { locations.Add(location); } else { return(BadRequest("Location not existed")); } } var locationSuggest = new LocationSuggestion { Comment = locationSuggestion.Comment, Locations = locations, UserId = userId, PlanId = locationSuggestion.PlanId, Status = RequestStatus.NotYet, PlanDay = locationSuggestion.PlanDay }; bool result = _planService.Create(locationSuggest); var plan = _planService.Find(locationSuggestion.PlanId, _ => _.Creator); var creatorGroup = plan.Creator; var content = new { to = $"{creatorGroup.MobileToken}", title = $"{(await CurrentUser()).FullName} muốn thêm { string.Join(", ", locations.Select(_ => _.Name)) } địa điểm vào chuyến đi {plan.Name}", body = $"{locationSuggestion.Comment}", data = new { type = "LocationSuggestion" } }; var temp = JsonConvert.SerializeObject(content); HttpResponseMessage responseMessage = await client.PostAsJsonAsync("/--/api/v2/push/send", content); if (result) { return(Ok()); } return(BadRequest()); } catch (Exception ex) { _loggingService.Write(GetType().Name, nameof(AddNoteToPlan), ex); return(InternalServerError(ex)); } }
public bool Create(LocationSuggestion locationSuggestion) { try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) { _locationSuggestionRepository.Create(locationSuggestion); _unitOfWork.SaveChanges(); scope.Complete(); return(true); } //end scope } catch (Exception ex) { _loggingService.Write(GetType().Name, nameof(Create), ex); return(false); } }
public bool RejectStatusLocationSuggestion(int suggestionId) { try { LocationSuggestion suggest = _locationSuggestionRepository.Get(_ => _.Id == suggestionId); suggest.Status = RequestStatus.Rejected; _locationSuggestionRepository.Update(suggest); _unitOfWork.SaveChanges(); return(true); } catch (Exception ex) { _loggingService.Write(GetType().Name, nameof(RejectStatusLocationSuggestion), ex); return(false); } }
private async void OnTextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) { if (args.Reason != AutoSuggestionBoxTextChangeReason.UserInput) { return; } FocusResult.Visibility = Visibility.Collapsed; var result = await MapLocationFinder.FindLocationsAsync(sender.Text, CurrentPosition); if (result.Status == MapLocationFinderStatus.Success && result.Locations.Any()) { sender.ItemsSource = LocationSuggestion.CreateFromMapFinderResult(result); } else { sender.ItemsSource = _failedMessageItemSource; } }
public GroupLocationSuggestionViewModels ConvertToGroupLocationSuggestionViewModels(LocationSuggestion locationSuggestion) { //need to edit return(new GroupLocationSuggestionViewModels { UserId = locationSuggestion.UserId, UserAvatar = locationSuggestion.User.Avatar, FullName = locationSuggestion.User.FullName, Comment = locationSuggestion.Comment, //LocationId = locationSuggestion.LocationId, //LocationName = locationSuggestion.Locations.Name, //LocationPhoto = locationSuggestion.Locations.Photos.FirstOrDefault(_ => _.IsPrimary)?.Photo.Id.ToString(), PlanId = locationSuggestion.PlanId, PlanName = locationSuggestion.Plan.Name, Status = (int)locationSuggestion.Status }); }