Exemplo n.º 1
0
        public void PopulateAssignedOwnerContacts(HOAContext context, Models.Owner owner)
        {
            var allContactTypes  = context.ContactType;
            var allOwnerContacts = context.OwnerContactType.Where(o => o.OwnerID == owner.OwnerID);
            var ownerContacts    = new HashSet <int>(owner.OwnerContactType.Select(o => o.ContactTypeID));

            AssignedOwnerContacts = new List <AssignedOwnerContactType>();

            foreach (var type in allContactTypes)
            {
                var contactInfo = "";
                foreach (var contact in allOwnerContacts)
                {
                    if (contact.ContactTypeID == type.ContactTypeID)
                    {
                        contactInfo = contact.ContactValue;
                        break;
                    }
                }

                AssignedOwnerContacts.Add(new AssignedOwnerContactType {
                    ContactTypeID    = type.ContactTypeID,
                    ContactTypeValue = type.Value,
                    ContactValue     = contactInfo,
                    Assigned         = ownerContacts.Contains(type.ContactTypeID)
                });
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Owner = await _context.Owner
                    .Include(o => o.User)
                    .Include(o => o.Address)
                    .Include(o => o.OwnerContactType).ThenInclude(c => c.ContactType)
                    .FirstOrDefaultAsync(m => m.OwnerID == id);

            if (Owner == null)
            {
                return(NotFound());
            }
            ViewData["ContactType"] = new List <ContactType>(_context.ContactType);
            ViewData["State"]       = States.GetStateSelectList(Owner.Address?.State);

            var owners = _context.Owner.Where(x => x.IsHoaOwner).Select(x => x.FullName).ToList();

            ViewData["Owners"]  = owners;
            ViewData["CoOwner"] = _context.Owner.FirstOrDefault(x => x.OwnerID == Owner.CoOwnerID)?.FullName;

            PopulateAssignedOwnerContacts(_context, Owner);

            return(Page());
        }
Exemplo n.º 3
0
        public ActionResult OwnertEdit(int id, Models.Owner o)
        {
            try
            {
                string        username = Convert.ToString(Session["id"]);
                SqlConnection con2     = new SqlConnection(@"Data Source=(localdb)\MsSqlLocalDb;Initial Catalog=project;Integrated Security=True");
                con2.Open();
                SqlCommand cmd2 = new SqlCommand();
                cmd2.Connection  = con2;
                cmd2.CommandType = CommandType.Text;
                cmd2.CommandText = "update Owner set Name=@Name,Phone=@Phone,Description=@Description,Address=@Address where Email=@Email";

                cmd2.Parameters.AddWithValue("Name", o.Name);
                cmd2.Parameters.AddWithValue("Phone", o.Phone);
                cmd2.Parameters.AddWithValue("Description", o.Description);
                cmd2.Parameters.AddWithValue("Address", o.Address);
                cmd2.Parameters.AddWithValue("Email", username);
                cmd2.ExecuteNonQuery();
                con2.Close();

                return(RedirectToAction("OwnerDetails", "Owner"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 4
0
        public ContactRegisterPageViewModel(Models.Owner owner, float imageAspectRatio)
        {
            this.RegisterCommand = new Command(this.ProcessRegistration);

            this.CurOwner         = owner;
            this.ImageAspectRatio = imageAspectRatio;
        }
Exemplo n.º 5
0
        //// GET: Owner/Edit/5
        public ActionResult OwnerEdit(int id = 0)
        {
            SqlConnection con = new SqlConnection(@"Data Source=(localdb)\MsSqlLocalDb;Initial Catalog=project;Integrated Security=True");

            con.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = con;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from  Owner where Email=@UserName";
            string username = Convert.ToString(Session["id"]);

            cmd.Parameters.AddWithValue("UserName", username);
            SqlDataReader dr = cmd.ExecuteReader();


            Models.Owner o = new Models.Owner();
            if (dr.Read())
            {
                o.Email       = Convert.ToString(dr["Email"]);
                o.Name        = Convert.ToString(dr["Name"]);
                o.Description = Convert.ToString(dr["Description"]);
                o.Phone       = Convert.ToInt64(dr["Phone"]);
                o.Address     = Convert.ToString(dr["Address"]);
                o.Latitude    = Convert.ToDouble(dr["Latitude"]);
                o.Longitude   = Convert.ToDouble(dr["Longitude"]);
            }

            con.Close();
            return(View(o));
        }
Exemplo n.º 6
0
        private async void GoNext()
        {
            if (this.IsBusy)
            {
                return;
            }
            this.IsBusy = true;

            if (!this.NextCommandEnabled)
            {
                this.IsBusy = false;
                return;
            }

            var owner = new Models.Owner()
            {
                Username = this.UsernameText,
                Email    = this.EmailText,
                Password = this.PasswordText,
                Location = new Models.Location()
            };

            await this.NavigationService.NavigateTo(typeof(ProfilePictureRegisterPage), new object[] { owner });

            this.IsBusy = false;
        }
Exemplo n.º 7
0
        public ProfilePictureRegisterPageViewModel(Models.Owner owner)
        {
            this.UploadCommand = new Command(this.UploadImage);
            this.NextCommand   = new Command(this.GoNext);

            this.CurOwner = owner;
        }
 public IActionResult OnGet(int?id)
 {
     #region LostItem Object
     LostItemObj = new LostItemVM()
     {
         LostItem = new Models.LostItem()
     };
     LostItemObj.LostItem = _unitOfWork.LostItem.GetFirstOrDefault(u => u.Id == id);
     if (LostItemObj == null)
     {
         return(NotFound());
     }
     #endregion
     #region Owner Object
     OwnerObj = _unitOfWork.Owner.GetFirstOrDefault(u => u.Id == LostItemObj.LostItem.OwnerId);
     if (OwnerObj == null)
     {
         return(NotFound());
     }
     #endregion
     #region Phone Number Formatting
     phoneNumber = String.Format("{0:(###) ###-####}", Convert.ToInt64(OwnerObj.PhoneNumber));
     #endregion
     #region Date Formatting
     date          = (LostItemObj.LostItem.Date);
     formattedDate = date.ToString("MM/dd/yyyy");
     #endregion
     return(Page());
 }
        public AddressRegisterSellerPageViewModel(Models.Owner owner, float imageAspectRatio, bool photoIsUploaded = false)
        {
            this.NextCommand = new Command(this.GoNext);

            this.CurOwner         = owner;
            this.ImageAspectRatio = imageAspectRatio;
            this.PhotoIsUploaded  = photoIsUploaded;
        }
Exemplo n.º 10
0
        public ContactRegisterPage(Models.Owner owner, float imageAspectRatio)
        {
            InitializeComponent();

            this.ViewModel = new ContactRegisterPageViewModel(owner, imageAspectRatio)
            {
                Title = this.Title
            };
            this.BindingContext = this.ViewModel;
        }
        public ProfilePictureRegisterPage(Models.Owner owner)
        {
            InitializeComponent();

            this.ViewModel = new ProfilePictureRegisterPageViewModel(owner)
            {
                Title = this.Title
            };
            this.BindingContext = this.ViewModel;
        }
Exemplo n.º 12
0
        public RestaurantRegisterSellerPage(Models.Owner owner)
        {
            InitializeComponent();

            this.ViewModel = new RestaurantRegisterSellerPageViewModel(owner)
            {
                Title = this.Title
            };
            this.BindingContext = this.ViewModel;
        }
Exemplo n.º 13
0
        private async Task <IList <Models.Menu> > LoadMenus(Models.Owner owner)
        {
            if (!CrossConnectivity.Current.IsConnected)
            {
                DependencyService.Get <IMessageHelper>().LongAlert($"Gagal memuat. Periksa kembali koneksi internet anda.");
                return(new List <Models.Menu>());
            }

            return(await MenuService.GetMenusFromOwnerId(owner));
        }
Exemplo n.º 14
0
 public Application.ReadModels.Owner Translate(Models.Owner from)
 {
     return(new Application.ReadModels.Owner
     {
         Age = (byte)from.Age,
         Name = from.Name,
         Gender = from.Gender.Parse <Gender>(),
         Pets = GetPetListOrEmptyListIfNull(from.Pets)
     });
 }
Exemplo n.º 15
0
        public static void CreateLangProfile(HttpContext ctx, Models.Owner owner)
        {
            var prof  = owner.langProfiles[0];
            var path  = System.IO.Path.Combine(owner.Path, $"{prof.ProfileName}_{DateTime.Now.ToString("yyyyMMMddHHmmss")}");
            var fpath = System.IO.Path.Combine(path, "_langprofile.json");

            System.IO.Directory.CreateDirectory(path);
            string keyidx = ctx.Request.Form["keyidxs"];
            var    lst    = Newtonsoft.Json.JsonConvert.DeserializeObject <List <int> >(keyidx);

            lst.ForEach(t =>
            {
                string inputtype  = ctx.Request.Form["inptdata" + t.ToString()];
                string inputlabel = ctx.Request.Form["inptlabel" + t.ToString()];
                if (inputtype == "filesrc")
                {
                    Microsoft.AspNetCore.Http.IFormFile fll = ctx.Request.Form.Files["uplfile" + t.ToString()];
                    string llpath = System.IO.Path.Combine(path, "LangData", "upl_File_" + (inputlabel ?? "") + "_" + fll.FileName);
                    if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(llpath)))
                    {
                        System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(llpath));
                    }
                    using (var stream = new System.IO.FileStream(llpath, System.IO.FileMode.Create))
                    {
                        fll.CopyTo(stream);
                    }
                    prof.Files.Add(new Models.LabelInput()
                    {
                        Label    = inputlabel,
                        FilePath = llpath
                    });
                }
                else if (inputtype == "textsrc")
                {
                    string txt    = ctx.Request.Form["upltext" + t.ToString()];
                    string llpath = System.IO.Path.Combine(path, "LangData", "upl_Text_" + (inputlabel ?? "") + "_" + Guid.NewGuid().ToString("n").Substring(0, 4) + ".txt");
                    if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(llpath)))
                    {
                        System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(llpath));
                    }
                    System.IO.File.WriteAllText(llpath, txt);
                    prof.Files.Add(new Models.LabelInput()
                    {
                        Label    = inputlabel,
                        FilePath = llpath
                    });
                }
            });

            prof.Path            = path;
            prof.ProfileFilePath = System.IO.Path.Combine(prof.Path, prof.ProfileName + ".bin.gz");
            prof.CreatedAt       = DateTime.UtcNow;
            prof.AccessedAt      = DateTime.UtcNow;
            System.IO.File.WriteAllText(fpath, Newtonsoft.Json.JsonConvert.SerializeObject(prof));
        }
Exemplo n.º 16
0
        private async void OpenOwnerDetail(Models.Owner owner)
        {
            if (this.IsBusy)
            {
                return;
            }
            this.IsBusy = true;

            await this.NavigationService.NavigateTo(typeof(OwnerDetailPage), new object[] { owner });

            this.IsBusy = false;
        }
Exemplo n.º 17
0
        private async void Save()
        {
            if (this.IsBusy)
            {
                return;
            }
            this.IsBusy = true;

            if (!this.SaveCommandEnabled)
            {
                this.IsBusy = false;
                return;
            }

            var loading = DependencyService.Get <ILoadingHelper>();

            loading.Show();

            Models.Owner owner = this.User.GetUser();
            owner.Location.Address   = this.AddressText;
            owner.Location.Latitude  = this.Point.Latitude;
            owner.Location.Longitude = this.Point.Longitude;

            var result = await AccountService.UpdateAccount(owner, null);

            loading.Hide();

            switch (result)
            {
            case ServerResponseStatus.INVALID:
                await this.NavigationService.CurrentPage.DisplayAlert("Pembaharuan Gagal", "Terjadi kesalahan pada server. Coba lagi nanti.", "OK");

                this.IsBusy = false;
                return;

            case ServerResponseStatus.ERROR:
                await this.NavigationService.CurrentPage.DisplayAlert("Pembaharuan Gagal", "Terjadi kesalahan pada server. Coba lagi nanti.", "OK");

                this.IsBusy = false;
                return;
            }

            this.User.SetUser(owner);

            DependencyService.Get <IMessageHelper>().LongAlert("Lokasi telah diperbaharui.");

            await this.NavigationService.GoBack();

            this.IsBusy = false;
        }
Exemplo n.º 18
0
        public MapDetailPage(Models.Owner owner)
        {
            InitializeComponent();

            this.ViewModel = new MapDetailPageViewModel(owner)
            {
                Title = this.Title
            };
            this.BindingContext = this.ViewModel;

            this.MyMap.MapStyle = MapStyle.FromJson(MAP_STYLE);
            this.MyMap.UiSettings.ZoomControlsEnabled     = false;
            this.MyMap.UiSettings.MyLocationButtonEnabled = true;
            this.MyMap.UiSettings.RotateGesturesEnabled   = false;
        }
Exemplo n.º 19
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Owner = await _context.Owner
                    .Include(o => o.Address).FirstOrDefaultAsync(m => m.OwnerID == id).ConfigureAwait(false);

            if (Owner == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemplo n.º 20
0
        public OwnerDetailPage(Models.Owner owner)
        {
            InitializeComponent();

            this.ViewModel = new OwnerDetailPageViewModel(owner)
            {
                Title = this.Title
            };
            this.BindingContext = this.ViewModel;

            this.MyMap.UiSettings.MyLocationButtonEnabled = false;
            this.MyMap.UiSettings.RotateGesturesEnabled   = false;
            this.MyMap.UiSettings.ScrollGesturesEnabled   = false;
            this.MyMap.UiSettings.TiltGesturesEnabled     = false;
            this.MyMap.UiSettings.ZoomControlsEnabled     = false;
            this.MyMap.UiSettings.ZoomGesturesEnabled     = false;
        }
Exemplo n.º 21
0
        protected override void Seed(ImoveisSystems.Models.ContextDB context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
            var Proprietario = new Models.Owner
                                   ("Gian", DateTime.Now.AddYears(-30), "*****@*****.**");

            if (context.Owners.FirstOrDefault(x => x.Name == "Gian") != null)
            {
                context.Owners.AddOrUpdate(Proprietario);
                context.Properties.AddOrUpdate(new Models.Property(
                                                   "89030070", "Casa", "Centro", "Blumenau", 234, "Frente a padaria", Proprietario));
                context.SaveChanges();
            }
        }
Exemplo n.º 22
0
        public void OnGet(int id)
        {
            Lot      = _unitOfWork.Lot.GetFirstOrDefault(l => l.Id == id);
            LotOwner = _unitOfWork.Lot_Owner.GetFirstOrDefault(lo => lo.LotId == id);

            if (LotOwner != null)
            {
                Owner = _unitOfWork.Owner.GetFirstOrDefault(o => o.Id == LotOwner.OwnerId);
            }
            else
            {
                Owner = new Models.Owner {
                    FirstName = "No", LastName = "Owner"
                };
            }

            KeyLots = _unitOfWork.KeyLot.GetAll(kl => kl.LotId == id, null, "Key,Lot");
        }
Exemplo n.º 23
0
        public OwnerDetailPageViewModel(Models.Owner owner)
        {
            this.SelectedOwner        = owner;
            this.SelectMenuCommand    = new Command <Models.Menu>(this.SelectMenu);
            this.OpenWhatsAppCommand  = new Command(this.OpenWhatsApp);
            this.ShareCommand         = new Command(this.ShareMenu);
            this.OpenMapDetailCommand = new Command(this.OpenMapDetail);
            Task.Run(async() =>
            {
                var list = await LoadMenus(owner);
                if (list == null)
                {
                    return;
                }

                this.MenuList = new ObservableCollection <Models.Menu>(list);

                this.HasMenu = ((this.MenuList?.Count > 0) && (this.MenuList != null)) ? true
                             : false;
                this.HasNoMenu = !this.HasMenu;
            }).Wait();
        }
Exemplo n.º 24
0
        public void CreateAffiliate(string affiliate)
        {
            var newOwner = new Models.Owner();

            var user = _context.Owner.FirstOrDefault(
                x => x.User.UserID == HttpContext.Session.GetInt32("SessionUserID"));

            newOwner.LastModifiedBy   = user != null ? user.Initials : "SYS";
            newOwner.LastModifiedDate = DateTime.Now;

            newOwner.IsHoaOwner = false;
            newOwner.IsPrimary  = false;

            newOwner.FirstName = affiliate.IndexOf(" ") > -1
                ? affiliate.Substring(0, affiliate.IndexOf(" "))
                : affiliate;
            newOwner.LastName = affiliate.IndexOf(" ") > -1
                ? affiliate.Substring(affiliate.IndexOf(" ") + 1)
                : "";

            _context.Owner.Add(newOwner);
            _context.SaveChanges();
        }
        public AddressRegisterSellerPage(Models.Owner owner, float imageAspectRatio, bool photoIsUploaded = false)
        {
            InitializeComponent();

            this.ViewModel = new AddressRegisterSellerPageViewModel(owner, imageAspectRatio, photoIsUploaded)
            {
                Title = this.Title
            };
            this.BindingContext = this.ViewModel;

            this.MyMap.MapStyle = MapStyle.FromJson(MAP_STYLE);
            this.MyMap.UiSettings.ZoomControlsEnabled     = false;
            this.MyMap.UiSettings.MyLocationButtonEnabled = true;
            this.MyMap.UiSettings.RotateGesturesEnabled   = false;

            Task.Run(async() =>
            {
                var myLocation = await LocationService.GetCurrentLocation(this.ViewModel);
                if (myLocation == null)
                {
                    return;
                }

                Position position = new Position(
                    myLocation.Latitude,
                    myLocation.Longitude);

                this.MyMap.MoveToRegion(
                    MapSpan.FromCenterAndRadius(
                        position,
                        Distance.FromMeters(
                            MAP_SPAN_RADIUS)));
            });

            this.AddressEntry.Focus();
        }
Exemplo n.º 26
0
        public IActionResult OnGet(int?id)
        {
            #region LostItem Object
            // Create the View Model
            LostItemObj = new LostItemVM()
            {
                LostItem = new Models.LostItem()
            };

            // Fill the View Model with the related information based on the Id of the Lost and Found Object
            LostItemObj.LostItem = _unitOfWork.LostItem.GetFirstOrDefault(u => u.Id == id);
            if (LostItemObj == null)
            {
                return(NotFound());
            }
            #endregion
            #region Owner Object
            // Create the Owner Object to grab Information from the Owner Table used for display purposes.
            OwnerObj = _unitOfWork.Owner.GetFirstOrDefault(u => u.Id == LostItemObj.LostItem.OwnerId);
            if (OwnerObj == null)
            {
                return(NotFound());
            }
            #endregion

            #region Phone Number Formatting
            phoneNumber = String.Format("{0:(###) ###-####}", Convert.ToInt64(OwnerObj.PhoneNumber)); //Format the PhoneNumber for display
            #endregion
            #region Date Formatting
            date          = (LostItemObj.LostItem.Date); // Grab the date.
            formattedDate = date.ToString("MM/dd/yyyy"); // Format the date for display.
            #endregion


            return(Page());
        }
Exemplo n.º 27
0
        public async Task <IActionResult> OnPostAsync(int?id, string[] selectedContacts, int?isAdmin, string coowner = "")
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            if (selectedContacts[0] == null || selectedContacts[2] == null)
            {
                ModelState.AddModelError("Contacts", "You must enter both a primary phone and email.");
                await OnGetAsync(id);

                return(Page());
            }

            Models.Owner ownerToUpdate = await _context.Owner
                                         .Include(o => o.Address)
                                         .Include(o => o.OwnerContactType).ThenInclude(c => c.ContactType)
                                         .FirstOrDefaultAsync(m => m.OwnerID == id);

            var user = _context.Owner.FirstOrDefault(
                x => x.User.UserID == HttpContext.Session.GetInt32("SessionUserID"));

            ownerToUpdate.LastModifiedBy   = user != null ? user.Initials : "SYS";
            ownerToUpdate.LastModifiedDate = DateTime.Now;

            ownerToUpdate.IsHoaOwner = true;
            ownerToUpdate.IsPrimary  = true;

            var owners = _context.Owner.Where(x => x.IsHoaOwner == true).Select(x => x.FullName).ToList();

            if (!owners.Contains(coowner) && !string.IsNullOrEmpty(coowner))
            {
                CreateCoOwner(coowner);
            }

            ownerToUpdate.CoOwnerID = _context.Owner.FirstOrDefault(x => x.FullName == coowner)?.OwnerID;

            selectedContacts[0] = selectedContacts[0] != null?Extensions.CleanPhone(selectedContacts[0]) : null;

            selectedContacts[1] = selectedContacts[1] != null?Extensions.CleanPhone(selectedContacts[1]) : null;

            selectedContacts[3] = selectedContacts[3] != null?Extensions.CleanPhone(selectedContacts[3]) : null;

            if (await TryUpdateModelAsync <Models.Owner>(
                    ownerToUpdate, "Owner",
                    o => o.Birthday, o => o.FirstName, o => o.LastName, o => o.Address, o => o.Occupation,
                    o => o.IsPrimary, o => o.IsHoaOwner, o => o.EmergencyContactName, o => o.EmergencyContactPhone,
                    o => o.LastModifiedBy, o => o.LastModifiedDate))
            {
                if (string.IsNullOrWhiteSpace(ownerToUpdate.Address?.FullAddress))
                {
                    ownerToUpdate.Address = null;
                }
                ownerToUpdate.EmergencyContactPhone = Extensions.CleanPhone(ownerToUpdate.EmergencyContactPhone);

                var email = selectedContacts[2];        //TODO: not super safe(will break if not in expected order
                UpdateUser(ownerToUpdate.OwnerID, isAdmin, email);

                //saves address
                _context.Attach(ownerToUpdate).State = EntityState.Modified;

                UpdateOwnerContacts(_context, selectedContacts, ownerToUpdate, user);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }

            UpdateOwnerContacts(_context, selectedContacts, ownerToUpdate, user);
            PopulateAssignedOwnerContacts(_context, ownerToUpdate);
            return(Page());
        }
Exemplo n.º 28
0
        private async void Save()
        {
            if (this.IsBusy)
            {
                return;
            }
            this.IsBusy = true;

            if (!this.saveCommandEnabled)
            {
                this.IsBusy = false;
                return;
            }

            var loading = DependencyService.Get <ILoadingHelper>();

            loading.Show();

            Models.Owner owner = this.User.GetUser();
            owner.Name        = this.NameText;
            owner.Headline    = this.HeadlineText;
            owner.OpeningHour = $"{this.OpeningTime:hh\\:mm}";
            owner.ClosingHour = $"{this.ClosingTime:hh\\:mm}";

            byte[] imageBytes = null;

            if (this.ImageIsChanged)
            {
                imageBytes = DependencyService.Get <IFileHelper>().ReadAllBytes(this.ImageSource);

                float width  = Constant.MEDIA_PHOTO_MENUIMAGE_SIZE;
                float height = width * this.ImageAspectRatio;
                imageBytes = DependencyService.Get <IMediaHelper>().ResizeImage(imageBytes, width, height);
            }

            var result = await AccountService.UpdateAccount(owner, imageBytes);

            loading.Hide();

            switch (result)
            {
            case ServerResponseStatus.INVALID:
                await this.NavigationService.CurrentPage.DisplayAlert("Pembaharuan Gagal", "Terjadi kesalahan pada server. Coba lagi nanti.", "OK");

                this.IsBusy = false;
                return;

            case ServerResponseStatus.ERROR:
                await this.NavigationService.CurrentPage.DisplayAlert("Pembaharuan Gagal", "Terjadi kesalahan pada server. Coba lagi nanti.", "OK");

                this.IsBusy = false;
                return;
            }

            this.User.SetUser(owner);

            DependencyService.Get <IMessageHelper>().ShortAlert("Akun telah diperbaharui.");

            await ImageService.Instance.InvalidateCacheAsync(FFImageLoading.Cache.CacheType.All);

            await this.NavigationService.GoBack();

            this.IsBusy = false;
        }
Exemplo n.º 29
0
 public MapDetailPageViewModel(Models.Owner owner)
 {
     this.SelectedOwner = owner;
 }
Exemplo n.º 30
0
        public static async Task <IList <Menu> > GetMenusFromOwnerId(Models.Owner owner)
        {
            try
            {
                var url        = "https://maempedia.com/menus.html";
                var requestURI = $"{url}?user_id={owner.ID}&key={apiKey}";

                var client   = new HttpClient();
                var request  = new HttpRequestMessage(HttpMethod.Get, requestURI);
                var response = await client.SendAsync(request);

                if (!response.IsSuccessStatusCode)
                {
                    Debug.WriteLine("Maempedia HTTP request denied.");
                    return(null);
                }

                var result = await response.Content.ReadAsStringAsync();

                if (result == null)
                {
                    Debug.WriteLine("Maempedia API has returned nothing.");
                    return(null);
                }

                JObject json = null;
                try
                {
                    json = JObject.Parse(result);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.InnerException);
                    return(null);
                }

                var menu_list = new List <Menu>();
                foreach (JObject menu in json["menu"])
                {
                    menu_list.Add(new Menu()
                    {
                        ID          = menu["id"].ToString(),
                        Name        = menu["name"].ToString(),
                        Headline    = menu["description"].ToString(),
                        Portion     = menu["portion"].ToString(),
                        ImageSource = "https://www." + menu["photo_url"].ToString(),
                        Price       = float.Parse(menu["price"].ToString()),
                        Like        = int.Parse(menu["like"].ToString()),
                        Promoted    = bool.Parse(menu["promoted"].ToString()),
                        PostID      = menu["post_id"].ToString(),
                        Owner       = owner
                    });
                }

                return(menu_list);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Maempedia HTTP issue: {0} {1}", ex.Message, ex);
                return(null);
            }
        }