public async Task <bool> Delete(PlaceGroup PlaceGroup) { if (await ValidateId(PlaceGroup)) { } return(PlaceGroup.IsValidated); }
public async Task <PlaceGroup> Get(long Id) { PlaceGroup PlaceGroup = await DataContext.PlaceGroup.AsNoTracking() .Where(x => x.Id == Id) .Where(x => x.DeletedAt == null) .Select(x => new PlaceGroup() { CreatedAt = x.CreatedAt, UpdatedAt = x.UpdatedAt, Id = x.Id, ParentId = x.ParentId, Name = x.Name, Code = x.Code, Parent = x.Parent == null ? null : new PlaceGroup { Id = x.Parent.Id, ParentId = x.Parent.ParentId, Name = x.Parent.Name, Code = x.Parent.Code, }, }).FirstOrDefaultAsync(); if (PlaceGroup == null) { return(null); } return(PlaceGroup); }
public void SetupSuggestion(PlaceGroup place, SearchField searchField) { isEnabled = true; this.place = place; this.searchField = searchField; text.text = place.placeInfo.name; }
IEnumerator GetAddress(PlaceGroup place, Action <string> action) { int number = 0; string address = string.Format("https://maps.googleapis.com/maps/api/geocode/json?latlng={0},{1}&location_type=ROOFTOP&result_type=street_address&key={2}", place.placeInfo.location.lat, place.placeInfo.location.lon, apiKey); using (UnityWebRequest www = UnityWebRequest.Get(address)) { yield return(www.Send()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { GoogleLocationApiResponse m = JsonConvert.DeserializeObject <GoogleLocationApiResponse>(www.downloadHandler.text); if (m.results.Length > 0) { action.Invoke(m.results[0].formatted_address); SaveAddressToList(place.placeInfo.id, m.results[0].formatted_address); } } } }
public async Task <ActionResult <PlaceGroup_PlaceGroupDTO> > Create([FromBody] PlaceGroup_PlaceGroupDTO PlaceGroup_PlaceGroupDTO) { if (!ModelState.IsValid) { throw new BindException(ModelState); } if (!await HasPermission(PlaceGroup_PlaceGroupDTO.Id)) { return(Forbid()); } PlaceGroup PlaceGroup = ConvertDTOToEntity(PlaceGroup_PlaceGroupDTO); PlaceGroup = await PlaceGroupService.Create(PlaceGroup); PlaceGroup_PlaceGroupDTO = new PlaceGroup_PlaceGroupDTO(PlaceGroup); if (PlaceGroup.IsValidated) { return(PlaceGroup_PlaceGroupDTO); } else { return(BadRequest(PlaceGroup_PlaceGroupDTO)); } }
public void NewPlace(PlaceGroup place, bool clickedOnMap = false) { // Save places if (savePlacesAfterReload) { savePlacesAfterReload = false; PlacesSave.Save(); } bool wait = true; if (TopBar.instance.currentTab == 2) { animator.SetTrigger("Change"); } else { wait = false; TopBar.instance.SwitchTab(2); } StopAllCoroutines(); if (!clickedOnMap) { RenderMap.instance.UpdateMapSize(0.3f); GlobalVariables.inst.MoveCamera(place.mapObject.gameObject.transform.position); place.mapObject.Select(); } this.place = place; StartCoroutine(AfterAnimationChange(wait)); }
public void NewPlace(PlaceGroup place, bool clickedOnMap = false) { ButtonTabs.instance.ClearCalendarView(); bool wait = true; if (TopBar.instance.currentTab == 2) { animator.SetTrigger("Change"); } else { wait = false; TopBar.instance.SwitchTab(2); } StopAllCoroutines(); if (!clickedOnMap) { RenderMap.instance.UpdateMapSize(0.3f); GlobalVariables.inst.MoveCamera(place.mapObject.gameObject.transform.position); place.mapObject.Select(true); } this.place = place; if (wait) { StartCoroutine(AfterAnimationChange()); } else { TasksAfterWaiting(); } }
public void Setup(ActivityType?type, double distance, float time, DateTime endTime, MovesJson.SegmentsInfo.PlaceInfo placeInfo) { this.type = type; this.distance = distance; this.time = time; if (placeInfo != null) { placeGroup = PlacesRanking.instance.FindPlace(placeInfo, this); this.placename = placeInfo.name; this.endTime = endTime; this.placeType = placeInfo.type; if (placeType == PlaceType.facebook) { placeFbId = placeInfo.facebookPlaceId; } } TimeSpan t = TimeSpan.FromSeconds(this.time); SetSize(t); endTimeText.text = string.Format("{0}:{1}", this.endTime.Hour.ToString().PadLeft(2, '0'), this.endTime.Minute.ToString().PadLeft(2, '0')); string timeShort = string.Format("{0}", t.Minutes); if (type == null) { place.SetActive(true); //place.GetComponent<Image>().color = placeGroup.Category.Category.color; //place.GetComponent<Image>().color = Color.white; //placeIcon.color = new Color(50, 50, 50); move.gameObject.SetActive(false); Header.text = placename; Subheader.gameObject.SetActive(false); //Subheader.text = timeShort; MoveType.gameObject.SetActive(false); MoveTime.gameObject.SetActive(false); MoveMinText.gameObject.SetActive(false); //if (distance >= 100) // Subheader.text += distance.ToString() + "m"; if (placeGroup.placeInfo != null) { placeIcon.sprite = placeGroup.IconSprite; } } else { place.SetActive(false); move.gameObject.SetActive(true); move.color = ReadJson.colors[(int)type]; Subheader.text = timeShort + distance.ToString() + "m"; Header.gameObject.SetActive(false); Subheader.gameObject.SetActive(false); MoveType.text = activityTypeText[(int)type.Value] + " "; MoveType.color = ReadJson.colors[(int)type]; MoveTime.text = timeShort; } }
public async Task <PlaceGroup> Get(long Id) { PlaceGroup PlaceGroup = await UOW.PlaceGroupRepository.Get(Id); if (PlaceGroup == null) { return(null); } return(PlaceGroup); }
public PlaceGroup_PlaceGroupDTO(PlaceGroup PlaceGroup) { this.Id = PlaceGroup.Id; this.ParentId = PlaceGroup.ParentId; this.Name = PlaceGroup.Name; this.Code = PlaceGroup.Code; this.Parent = PlaceGroup.Parent == null ? null : new PlaceGroup_PlaceGroupDTO(PlaceGroup.Parent); this.CreatedAt = PlaceGroup.CreatedAt; this.UpdatedAt = PlaceGroup.UpdatedAt; this.Errors = PlaceGroup.Errors; }
public Place_PlaceGroupDTO(PlaceGroup PlaceGroup) { this.Id = PlaceGroup.Id; this.ParentId = PlaceGroup.ParentId; this.Name = PlaceGroup.Name; this.Code = PlaceGroup.Code; this.Errors = PlaceGroup.Errors; }
public void GetPlaceAddress(PlaceGroup place, Action <string> action) { StopAllCoroutines(); if (placesAddressSave.ContainsKey(place.placeInfo.id)) { action.Invoke(placesAddressSave[place.placeInfo.id]); } else { StartCoroutine(GetAddress(place, action)); } }
public void SetupPlace(MovesJson.SegmentsInfo.PlaceInfo placeInfo) { place = PlacesRanking.instance.FindPlace(placeInfo, this); if (placeInfo.name == null) { text.text = "???"; } else { text.text = place.placeInfo.name; } }
public PlaceGroup FindPlace(MovesJson.SegmentsInfo.PlaceInfo place, ActivityUI timelineObject) { PlaceGroup thisPlace = new PlaceGroup(); if (places.TryGetValue(place.id, out thisPlace)) { thisPlace.AddTimelineObject(timelineObject); return(thisPlace); } else { return(null); } }
public PlaceGroup FindPlace(MovesJson.SegmentsInfo.PlaceInfo place, Place mapObject) { PlaceGroup thisPlace = new PlaceGroup(); if (places.TryGetValue(place.id, out thisPlace)) { thisPlace.AddMapObject(mapObject); return(thisPlace); } else { return(null); } }
public async Task <bool> Delete(PlaceGroup PlaceGroup) { PlaceGroupDAO PlaceGroupDAO = await DataContext.PlaceGroup.Where(x => x.Id == PlaceGroup.Id).FirstOrDefaultAsync(); await DataContext.PlaceGroup.Where(x => x.Path.StartsWith(PlaceGroupDAO.Id + ".")).UpdateFromQueryAsync(x => new PlaceGroupDAO { DeletedAt = StaticParams.DateTimeNow, UpdatedAt = StaticParams.DateTimeNow }); await DataContext.PlaceGroup.Where(x => x.Id == PlaceGroup.Id).UpdateFromQueryAsync(x => new PlaceGroupDAO { DeletedAt = StaticParams.DateTimeNow, UpdatedAt = StaticParams.DateTimeNow }); await BuildPath(); return(true); }
void AddOrSetupRanking(MovesJson.SegmentsInfo.PlaceInfo place, MovesJson day, MovesJson.SegmentsInfo segmentInfo) { PlaceGroup placeTarget = new PlaceGroup(); if (places.TryGetValue(place.id, out placeTarget)) { placeTarget.timesVisited += 1; placeTarget.AddHoursSplit(ReadJson.ReturnDateTime(segmentInfo.startTime), ReadJson.ReturnDateTime(segmentInfo.endTime)); } else { placeTarget = new PlaceGroup(place, ReadJson.ReturnDateTime(segmentInfo.startTime), ReadJson.ReturnDateTime(segmentInfo.endTime)); places.Add(place.id, placeTarget); } placeTarget.lastVisited = ReadJson.ReturnSimpleDate(day.date); }
public async Task <ActionResult <PlaceGroup_PlaceGroupDTO> > Get([FromBody] PlaceGroup_PlaceGroupDTO PlaceGroup_PlaceGroupDTO) { if (!ModelState.IsValid) { throw new BindException(ModelState); } if (!await HasPermission(PlaceGroup_PlaceGroupDTO.Id)) { return(Forbid()); } PlaceGroup PlaceGroup = await PlaceGroupService.Get(PlaceGroup_PlaceGroupDTO.Id); return(new PlaceGroup_PlaceGroupDTO(PlaceGroup)); }
private PlaceGroup ConvertDTOToEntity(PlaceGroup_PlaceGroupDTO PlaceGroup_PlaceGroupDTO) { PlaceGroup PlaceGroup = new PlaceGroup(); PlaceGroup.Id = PlaceGroup_PlaceGroupDTO.Id; PlaceGroup.ParentId = PlaceGroup_PlaceGroupDTO.ParentId; PlaceGroup.Name = PlaceGroup_PlaceGroupDTO.Name; PlaceGroup.Code = PlaceGroup_PlaceGroupDTO.Code; PlaceGroup.Parent = PlaceGroup_PlaceGroupDTO.Parent == null ? null : new PlaceGroup { Id = PlaceGroup_PlaceGroupDTO.Parent.Id, ParentId = PlaceGroup_PlaceGroupDTO.Parent.ParentId, Name = PlaceGroup_PlaceGroupDTO.Parent.Name, Code = PlaceGroup_PlaceGroupDTO.Parent.Code, }; PlaceGroup.BaseLanguage = CurrentContext.Language; return(PlaceGroup); }
public async Task <bool> ValidateId(PlaceGroup PlaceGroup) { PlaceGroupFilter PlaceGroupFilter = new PlaceGroupFilter { Skip = 0, Take = 10, Id = new IdFilter { Equal = PlaceGroup.Id }, Selects = PlaceGroupSelect.Id }; int count = await UOW.PlaceGroupRepository.Count(PlaceGroupFilter); if (count == 0) { PlaceGroup.AddError(nameof(PlaceGroupValidator), nameof(PlaceGroup.Id), ErrorCode.IdNotExisted); } return(count == 1); }
public async Task <PlaceGroup> Delete(PlaceGroup PlaceGroup) { if (!await PlaceGroupValidator.Delete(PlaceGroup)) { return(PlaceGroup); } try { await UOW.PlaceGroupRepository.Delete(PlaceGroup); await Logging.CreateAuditLog(new { }, PlaceGroup, nameof(PlaceGroupService)); return(PlaceGroup); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(PlaceGroupService)); } return(null); }
public async Task <bool> Create(PlaceGroup PlaceGroup) { PlaceGroupDAO PlaceGroupDAO = new PlaceGroupDAO(); PlaceGroupDAO.Id = PlaceGroup.Id; PlaceGroupDAO.ParentId = PlaceGroup.ParentId; PlaceGroupDAO.Name = PlaceGroup.Name; PlaceGroupDAO.Code = PlaceGroup.Code; PlaceGroupDAO.Path = ""; PlaceGroupDAO.Level = 1; PlaceGroupDAO.CreatedAt = StaticParams.DateTimeNow; PlaceGroupDAO.UpdatedAt = StaticParams.DateTimeNow; DataContext.PlaceGroup.Add(PlaceGroupDAO); await DataContext.SaveChangesAsync(); PlaceGroup.Id = PlaceGroupDAO.Id; await SaveReference(PlaceGroup); await BuildPath(); return(true); }
public async Task <bool> Update(PlaceGroup PlaceGroup) { PlaceGroupDAO PlaceGroupDAO = DataContext.PlaceGroup.Where(x => x.Id == PlaceGroup.Id).FirstOrDefault(); if (PlaceGroupDAO == null) { return(false); } PlaceGroupDAO.Id = PlaceGroup.Id; PlaceGroupDAO.ParentId = PlaceGroup.ParentId; PlaceGroupDAO.Name = PlaceGroup.Name; PlaceGroupDAO.Code = PlaceGroup.Code; PlaceGroupDAO.Path = ""; PlaceGroupDAO.Level = 1; PlaceGroupDAO.UpdatedAt = StaticParams.DateTimeNow; await DataContext.SaveChangesAsync(); await SaveReference(PlaceGroup); await BuildPath(); return(true); }
public async Task <PlaceGroup> Update(PlaceGroup PlaceGroup) { if (!await PlaceGroupValidator.Update(PlaceGroup)) { return(PlaceGroup); } try { var oldData = await UOW.PlaceGroupRepository.Get(PlaceGroup.Id); await UOW.PlaceGroupRepository.Update(PlaceGroup); PlaceGroup = await UOW.PlaceGroupRepository.Get(PlaceGroup.Id); await Logging.CreateAuditLog(PlaceGroup, oldData, nameof(PlaceGroupService)); return(PlaceGroup); } catch (Exception ex) { await Logging.CreateSystemLog(ex, nameof(PlaceGroupService)); } return(null); }
public void GetPlaceAddress(PlaceGroup place, Action <string> action) { StopAllCoroutines(); StartCoroutine(GetAddress(place, action)); }
private async Task SaveReference(PlaceGroup PlaceGroup) { }
public async Task <bool> Create(PlaceGroup PlaceGroup) { return(PlaceGroup.IsValidated); }
public async Task <ActionResult> Import(IFormFile file) { if (!ModelState.IsValid) { throw new BindException(ModelState); } List <PlaceGroup> PlaceGroups = new List <PlaceGroup>(); using (ExcelPackage excelPackage = new ExcelPackage(file.OpenReadStream())) { ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.FirstOrDefault(); if (worksheet == null) { return(Ok(PlaceGroups)); } int StartColumn = 1; int StartRow = 1; int IdColumn = 0 + StartColumn; int ParentIdColumn = 1 + StartColumn; int NameColumn = 2 + StartColumn; int CodeColumn = 3 + StartColumn; int UsedColumn = 7 + StartColumn; for (int i = StartRow; i <= worksheet.Dimension.End.Row; i++) { if (string.IsNullOrEmpty(worksheet.Cells[i + StartRow, StartColumn].Value?.ToString())) { break; } string IdValue = worksheet.Cells[i + StartRow, IdColumn].Value?.ToString(); string ParentIdValue = worksheet.Cells[i + StartRow, ParentIdColumn].Value?.ToString(); string NameValue = worksheet.Cells[i + StartRow, NameColumn].Value?.ToString(); string CodeValue = worksheet.Cells[i + StartRow, CodeColumn].Value?.ToString(); string UsedValue = worksheet.Cells[i + StartRow, UsedColumn].Value?.ToString(); PlaceGroup PlaceGroup = new PlaceGroup(); PlaceGroup.Name = NameValue; PlaceGroup.Code = CodeValue; PlaceGroups.Add(PlaceGroup); } } PlaceGroups = await PlaceGroupService.Import(PlaceGroups); if (PlaceGroups.All(x => x.IsValidated)) { return(Ok(true)); } else { List <string> Errors = new List <string>(); for (int i = 0; i < PlaceGroups.Count; i++) { PlaceGroup PlaceGroup = PlaceGroups[i]; if (!PlaceGroup.IsValidated) { string Error = $"Dòng {i + 2} có lỗi:"; if (PlaceGroup.Errors.ContainsKey(nameof(PlaceGroup.Id))) { Error += PlaceGroup.Errors[nameof(PlaceGroup.Id)]; } if (PlaceGroup.Errors.ContainsKey(nameof(PlaceGroup.ParentId))) { Error += PlaceGroup.Errors[nameof(PlaceGroup.ParentId)]; } if (PlaceGroup.Errors.ContainsKey(nameof(PlaceGroup.Name))) { Error += PlaceGroup.Errors[nameof(PlaceGroup.Name)]; } if (PlaceGroup.Errors.ContainsKey(nameof(PlaceGroup.Code))) { Error += PlaceGroup.Errors[nameof(PlaceGroup.Code)]; } Errors.Add(Error); } } return(BadRequest(Errors)); } }
public void SetupPlace(MovesJson.SegmentsInfo.PlaceInfo placeInfo) { place = PlacesRanking.instance.FindPlace(placeInfo, this); text.text = place.placeInfo.name; }