public async Task <IActionResult> Put(int id, [FromBody] HostelModel model)
        {
            var hostel = await this.hostelService.GetById(id);

            if (hostel != null)
            {
                hostel.Name        = model.Name;
                hostel.PhoneNumber = model.PhoneNumber;
                hostel.CurrencyId  = model.Currency.Id;
                hostel.LocationId  = model.Location.Id;
                hostel.Email       = model.Email;

                try
                {
                    await this.hostelService.Update(hostel);

                    return(this.Ok());
                }
                catch (HostaliandoException e)
                {
                    return(this.BadRequest(e));
                }
            }
            else
            {
                return(this.NotFound());
            }
        }
Ejemplo n.º 2
0
        public async void PostHostelNameSuccess(string resultHostel)
        {
            updateHostel = new UpdateHostel();
            HostelModel  = new HostelModel();
            await App.Current.MainPage.DisplayAlert("HMS", resultHostel, "OK");

            OnPropertyChanged("updateHostel");
            OnPropertyChanged("HostelModel");
        }
Ejemplo n.º 3
0
        private void lv_role_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            HostelModel md  = (HostelModel)lv_role.SelectedItem;
            int         cnt = vm.HostelModelList.IndexOf(md);

            if (cnt >= 0)
            {
                vm.selectedhostel(cnt);
            }
        }
Ejemplo n.º 4
0
        private void OnSelectedHostelItem(object sender, ItemTappedEventArgs e)
        {
            HostelModel md  = (HostelModel)lv_hostel.SelectedItem;
            int         cnt = VM.HostelModelList.IndexOf(md);

            if (cnt >= 0)
            {
                VM.HostelSelection(cnt);
            }

            ((ListView)sender).SelectedItem = null;
        }
Ejemplo n.º 5
0
        public void SaveAsync()
        {
            string emailpattern = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
            Regex  emailRegx    = new Regex(emailpattern);

            if (IsCheck1 == true)
            {
                HostelGender = "Male";
            }
            else
            {
                HostelGender = "Female";
            }
            //  Hostel.hostelName = HostelName;
            if (AreaId == null)
            {
                App.Current.MainPage.DisplayAlert("", "Please Select Area", "OK");
            }
            else if (HostelName == null || HostelName.Length == 0)
            {
                App.Current.MainPage.DisplayAlert("", "Please Enter Hostel Name", "OK");
            }
            else if (emailRegx.IsMatch(Email) == false)
            {
                App.Current.MainPage.DisplayAlert("HMS", "Enter Valid Email Address", "OK");
                return;
            }

            else
            {
                HostelModel Hostels = new HostelModel();
                Hostels.hostelName      = HostelName;
                Hostels.areaId          = AreaId;
                Hostels.hostelForGender = HostelGender;
                Hostels.addressLine1    = Address;
                Hostels.zipCode         = Zipcode;
                Hostels.phone           = Phone;
                Hostels.email           = Email;
                web.SaveHostelEntry(Hostels);
                // new CountryReportService((AreaEntryI)this).SaveAreaEntry(Area);
            }
        }
        public async Task <IActionResult> Post([FromBody] HostelModel model)
        {
            if (model.Sources == null || model.Sources.Count == 0)
            {
                this.ModelState.AddModelError("Sources", "Al menos debe ingresar un origen de datos");
                return(this.BadRequest(this.ModelState));
            }

            var hostel = model.ToEntity();

            try
            {
                await this.hostelService.Insert(hostel);

                return(this.Created("ApiGetHostel", hostel.Id));
            }
            catch (HostaliandoException e)
            {
                return(this.BadRequest(e));
            }
        }
Ejemplo n.º 7
0
        // GET: ViewHostel

        public ActionResult Index(string option, string search, int?i)
        {
            List <HostelModel> hostelList = new List <HostelModel>();

            hostelList.Add(new HostelModel());
            float avr = 0;

            foreach (var item in db.tbl_Hostel_Images.ToList())
            {
                tbl_Hostel_Detail hostel_Detail = db.tbl_Hostel_Detail.Where(x => x.H_Id == item.H_Id).FirstOrDefault();
                List <tbl_Rating> ratings       = db.tbl_Rating.Where(x => x.H_Id == hostel_Detail.H_Id).ToList();
                if (ratings.Count != 0)
                {
                    avr = (int)(ratings.Sum(x => x.R_Name)) / ratings.Count;
                }
                if (!(hostelList.Any(x => x.H_Id == hostel_Detail.H_Id)))
                {
                    HostelModel hostel = new HostelModel();
                    hostel.H_Id              = hostel_Detail.H_Id;
                    hostel.H_Name            = hostel_Detail.H_Name;
                    hostel.H_Address         = hostel_Detail.H_Address;
                    hostel.I_Name            = item.I_Name;
                    hostel.Rating            = avr;
                    hostel.H_Near_University = hostel_Detail.H_Near_University;
                    hostel.H_Area            = hostel_Detail.H_Area;
                    hostelList.Add(hostel);
                }
            }
            List <HostelModel> nearUni = new List <HostelModel>();

            if (option == "H_Near_University")
            {
                foreach (HostelModel item in hostelList)
                {
                    if (item.H_Near_University == search)
                    {
                        nearUni.Add(item);
                    }
                }
                return(View(nearUni.ToPagedList(i ?? 1, 6)));
            }

            else if (option == "H_Area")
            {
                List <HostelModel> nearAre = new List <HostelModel>();
                foreach (HostelModel item in hostelList)
                {
                    if (item.H_Area == search)
                    {
                        nearAre.Add(item);
                    }
                }
                return(View(nearAre.ToPagedList(i ?? 1, 6)));
            }

            else
            {
                return(View(hostelList.ToPagedList(i ?? 1, 6)));
            }

            //if (option == "H_Near_University")
            //{
            //    var data = db.tbl_Hostel_Images.SqlQuery("select * from tbl_Hostel_Images d join tbl_Hostel_Detail i on d.H_Id = i.H_Id where H_Near_University=@p0", search).ToList().ToPagedList(i ?? 1, 9);
            //    return View(data);
            //}
            //else if (option == "H_Area")
            //{
            //    var data = db.tbl_Hostel_Images.SqlQuery("select * from tbl_Hostel_Images d join tbl_Hostel_Detail i on d.H_Id = i.H_Id where H_Area=@p0", search).ToList().ToPagedList(i ?? 1, 9);
            //    return View(data);
            //}
            //else
            //{
            //    var data = db.tbl_Hostel_Images.SqlQuery("select * from tbl_Hostel_Images d join tbl_Hostel_Detail i on d.H_Id = i.H_Id ").ToList().ToPagedList(i ?? 1, 9);
            //    return View(data);
            //}
        }