Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)
        {
            int advertID = 0;

            if (!int.TryParse(Request.QueryString["id"], out advertID))
                Response.Redirect("/");

            GetAdvertResult advert = new UltimateDataContext().GetAdvert(advertID).Single<GetAdvertResult>();

            if (!advert.PlaceberryAdvert)
            {
                advertframe.Attributes.Add("src", advert.URLLink);
            }
            else if (advert.AccommodationId.HasValue)
            {
                Response.Redirect(String.Format("/AgencyListing.aspx?id={0}", advert.AccommodationId.Value), true);
            }
            else
            {
                Response.Redirect("/", true);
            }
        }
        else
            Response.Redirect("/", true);
    }
Exemplo n.º 2
0
    protected UltimateDC.Agency GetAgency()
    {
        if (_agency == null)
        {
            UltimateDataContext dc = new UltimateDataContext();

            int agencyId = 0;

            if (Int32.TryParse(Request.QueryString["agencyid"], out agencyId))
            {
                bool isAdmin = User.IsInRole("Administrators");

                _agency = (from p in dc.Agencies
                           where p.Id == agencyId && (isAdmin || p.PlaceberryUser.aspnet_User.UserName == User.Identity.Name)
                           select p).SingleOrDefault();
            }

            if (_agency == null)
            {
                //Ne postoji ili trenutni korisnik nema prava
                Response.Redirect("/manage/customer.aspx");
            }
        }

        return _agency;
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        bool admin = User.IsInRole("Administrators");

        plhAdminOptions.Visible = admin;

        using (UltimateDataContext dc = new UltimateDataContext())
        {
            var agencies = from p in dc.Agencies
                           where admin || p.ManagerId == (Guid)Membership.GetUser().ProviderUserKey
                           select p;

            if (agencies.Any())
            {
                //Ako je samo jedna onda neka odmah ide na stranicu s agencijom
                if (agencies.Count() == 1 && !admin)
                    Response.Redirect(String.Format("/manage/Agency.aspx?agencyId={0}", agencies.Single().Id));

                repAgencies.DataSource = agencies;
                repAgencies.DataBind();

            }
            else if(!admin)
            {
                //Ako nema ni jedne Agencije neka korisnik stvori novu agenciju
                Response.Redirect(String.Format("/manage/Agency.aspx?action=newagency"));

            }
        }
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var cookie = Request.Cookies.Get("savedAds");
        if (cookie != null)
        {
            string vals = cookie.Value;
            if (!string.IsNullOrEmpty(vals))
            {
                int ad = 0;
                var list = from p in HttpUtility.UrlDecode(vals).Split(',')
                           select int.TryParse(p, out ad) ? ad : -1;
                var listfiltered = (from p in list
                                    where p != -1
                                    select p).Distinct().ToList();

                if (listfiltered.Any())
                {
                    using (UltimateDataContext dc = new UltimateDataContext())
                    {
                        var favoriteAds = from p in dc.Adverts
                                          where listfiltered.Contains(p.Id)
                                          select new
                                          {
                                              Id = p.Id,
                                              Title = p.Title,
                                          };
                        repFavoriteAds.DataSource = favoriteAds;
                        repFavoriteAds.DataBind();
                    }
                }

            }
        }
    }
Exemplo n.º 5
0
    protected void GetChildren()
    {
        using (UltimateDataContext dc = new UltimateDataContext())
        {
            var children = from p in dc.UltimateTableRelations
                           where p.Active == true && p.Child.Active == true &&
                                p.Parent.Title.ToLower() == parentTerm && p.Child.UltimateTableObjectType.GroupCode == "GEO"
                           select p.Child;

            var parents = from p in dc.UltimateTableRelations
                          where p.Active == true && p.Parent.Active == true &&
                                p.Child.Title.ToLower() == parentTerm
                          select p.Parent;

            var brothers = from p in dc.UltimateTableRelations
                           where p.Active == true && p.Child.Active == true &&
                                parents.Contains(p.Parent) && p.Child.Title.ToLower() != parentTerm && p.Child.UltimateTableObjectType.GroupCode == "GEO"
                           select p.Child;

            //Ako parent nema djece onda ispisuje braću
            var query = children.Any() ? children : brothers;

            //LEFT OUTER JOIN pa ako nema prijevoda onda prikazujemo Title iz UltimateTable
            var translation = from p in query
                              join q in dc.UltimateTableTranslations on p equals q.UltimateTable into trans
                              from r in trans.Where(i => i.Language.Abbrevation == language && i.Active == true).DefaultIfEmpty()
                              select new
                              {
                                  UltimateId = p.Id,
                                  Title = r != null ? r.Title : p.Title
                              };

            if (translation.Any())
            {
                var trans = translation.Take(1).SingleOrDefault();
                var parentnodes = (from p in dc.GetParents(null, trans.UltimateId, Common.GetLanguageId())
                                   select p.ParentTitle).ToArray();
                //string parentlink = parentnodes.Any() ? string.Join(" ", parentnodes) + " " : string.Empty;

                aParent.HRef = string.Format("{0}?{1}{2}={3}", landingPage, queryString, queryStringVar, HttpUtility.UrlEncode(parentnodes.Last()));
                aParent.InnerText = parentnodes.Last();

                var data = from p in translation
                           select new
                           {
                               Href = String.Format("{0}?{1}{2}={3}", landingPage, queryString, queryStringVar, HttpUtility.UrlEncode(p.Title)),
                               Title = p.Title
                           };

                repDirectory.DataSource = data;
                repDirectory.DataBind();
            }

        }
    }
Exemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime arrivDate;
        int numOfDays;
        int numOfPers;

        if (DateTime.TryParse(Request.QueryString["arrivDate"], out arrivDate)
            && Int32.TryParse(Request.QueryString["numOfDays"], out numOfDays)
            && Int32.TryParse(Request.QueryString["numOfPers"], out numOfPers))
        {
            XDocument xdoc = new XDocument(new XElement("root"));

            if (arrivDate > DateTime.Now)
            {
                List<Booking> lstBook = Booking.GetAllBookingsForAgency(NOVAK_AGENCY_ID, true, null);

                UltimateDataContext dc = new UltimateDataContext();

                var accommodations = from a in dc.Accommodations
                                        where a.AgencyId == NOVAK_AGENCY_ID
                                        select a;

                foreach (var accomm in accommodations)
                {
                    bool isAvail = numOfPers <= accomm.CapacityMax;

                    if (isAvail)
                    {
                        List<Booking> thisAccommBookings = (from b in lstBook
                                                            where b.AccommodationId == accomm.Id
                                                            select b).ToList<Booking>();

                        isAvail = CheckDateAvail(thisAccommBookings, numOfDays, arrivDate);
                    }

                    if (isAvail)
                    {
                        xdoc.Root.Add(new XElement("itemId", accomm.Id.ToString()));
                    }
                }

                //XDocument doc = new XDocument(
                //new XElement("root",
                //         new XAttribute("name", "value"),
                //         new XElement("child", "text node")));
            }

            Response.Clear();
            Response.ContentType = "text/xml; encoding='utf-8'";
            Response.Write(xdoc.ToString());
            Response.End();
        }
    }
Exemplo n.º 7
0
    public static bool CheckAgencyExists(string agency)
    {
        bool exists = false;
        agency = agency == null ? string.Empty : agency.Trim().ToLower();

        using (UltimateDataContext dc = new UltimateDataContext())
        {
            exists = dc.Agencies.Any(i => i.Name.ToLower() == agency);
        }

        return exists;
    }
Exemplo n.º 8
0
    public IEnumerable GetChildrenByType(int? parentId, int? childTypeId, int? languageId)
    {
        IEnumerable children = null;

        using (UltimateDataContext dc = new UltimateDataContext())
        {
            children = (from p in dc.GetParentChildsByType(parentId, childTypeId, languageId)
                       orderby p.ParentTitle ascending
                       select new
                       {
                           Id = p.ChildId,
                           Title = p.ChildTitle
                       }).ToList();
        }

        return children;
    }
Exemplo n.º 9
0
    public IEnumerable GetParents(string childTitle, int? childId, int? languageId)
    {
        IEnumerable parents = null;

        using (UltimateDataContext dc = new UltimateDataContext())
        {
            parents = (from p in dc.GetParents(null, childId, languageId)
                       orderby p.ParentTitle ascending
                       select new
                       {
                           Id = p.ParentId,
                           Title = p.ParentTitle,
                           Type = p.ObjectTypeCode
                       }).ToList();
        }

        return parents;
    }
Exemplo n.º 10
0
    public IEnumerable GetParentCities(int countryId, int? languageId)
    {
        IEnumerable cities = null;

        using (UltimateDataContext dc = new UltimateDataContext())
        {
            cities = (from p in dc.GetParentCities(countryId, languageId)
                      orderby p.ChildTitle ascending
                      select new
                      {
                          Id = p.ChildId.Value,
                          Title = p.ChildTitle,
                          DisplayTitle = String.Format("{0}, {1}", p.ChildTitle, p.ParentTitle)
                      }).ToList();
        }

        return cities;
    }
Exemplo n.º 11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (UltimateDC.UltimateDataContext dc = new UltimateDC.UltimateDataContext())
         {
             repPopularQueries.DataSource = (from p in dc.PopularQueries
                                             where p.Active == true && p.LanguageId == Common.GetLanguageId()
                                             orderby p.Priority descending
                                             select new
                                             {
                                                 Title = p.Query,
                                                 Link = String.Format("/{0}?q={1}", Resources.placeberry.General_VacationUrl, HttpUtility.UrlEncode(p.Query))
                                             }).Take(12);
             repPopularQueries.DataBind();
         }
     }
 }
Exemplo n.º 12
0
    private void DoActivate()
    {
        mvwLogin.ActiveViewIndex = 1;

        string activationkey = Request.QueryString["activationkey"];
        if (!string.IsNullOrEmpty(activationkey))
        {
            Guid key = new Guid(activationkey);
            using (UltimateDataContext dc = new UltimateDataContext())
            {
                var user = (from p in dc.PlaceberryUsers
                            where p.ActivationKey.HasValue && p.ActivationKey.Value == key
                            select p).SingleOrDefault();

                if (user != null)
                {
                    user.aspnet_User.aspnet_Membership.IsApproved = true;
                    user.ActivationKey = null;

                    dc.SubmitChanges();

                    FormsAuthentication.SetAuthCookie(user.aspnet_User.UserName, true);

                    ltlSucess.Visible = true;

                    Response.AddHeader("REFRESH", "3;URL=/manage");
                }
                else
                {
                    ltlError.Visible = true;
                }
            }
        }
        else
        {
            ltlError.Visible = true;
        }
    }
Exemplo n.º 13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int bookingId;
            if (!Int32.TryParse(Request.QueryString["bookid"], out bookingId))
            {
                this.phMainContent.Visible = false;
                this.phError.Visible = true;
                this.ltErrMsg.Text = "Error: Missing bookid parametar!";
                return;
                //Response.Redirect("/manage/customer.aspx");
            }

            Booking booking = Booking.GetBooking(bookingId);

            if (booking == null)
            {
                this.phMainContent.Visible = false;
                this.phError.Visible = true;
                this.ltErrMsg.Text = "Error: Booking not found in database!";
                return;
                //Response.Redirect("/manage/customer.aspx");
            }

            UltimateDataContext dc = new UltimateDataContext();

            UltimateDC.Accommodation accommodation = (from a in dc.Accommodations
                                                      where a.Id == booking.AccommodationId
                                                      select a).SingleOrDefault();

            if (accommodation == null)
            {
                this.phMainContent.Visible = false;
                this.phError.Visible = true;
                this.ltErrMsg.Text = "Error: Accommodation not found in database!";
                return;
                //Response.Redirect("/manage/customer.aspx");
            }

            // kako je ovo booking sa admina provjeriti prava
            bool isAdmin = User.IsInRole("Administrators");

            UltimateDC.Agency agency = (from p in dc.Agencies
                                        where p.Id == accommodation.AgencyId && (isAdmin || p.PlaceberryUser.aspnet_User.UserName == User.Identity.Name) // svaka agencija ima samo jednog usera pa ako nije admin provjeriti dali je user od pripadajuce agencije
                                        select p).SingleOrDefault();

            if (agency == null)
            {
                this.phMainContent.Visible = false;
                this.phError.Visible = true;
                this.ltErrMsg.Text = "Error: Access not allowed!";
                return;
                //Response.Redirect("/manage/customer.aspx");
            }

            this.hfAccommodationId.Value = accommodation.Id.ToString();
            this.hfBookingId.Value = bookingId.ToString();

            ddlStatus.Items.Add(new ListItem("T", "T"));
            ddlStatus.Items.Add(new ListItem("O", "O"));
            ddlStatus.SelectedValue = booking.Status.ToString();

            tbPriceBasic.Text = booking.PriceBasic.ToString();
            tbPriceSum.Text = booking.PriceSum.ToString();

            var currencies = from c in dc.Currencies
                             select c;

            foreach (var c in currencies)
            {
                this.ddlCurrency.Items.Add(new ListItem(c.Abbrevation, c.Id.ToString()));
            }

            this.ddlCurrency.SelectedValue = booking.CurrencyId.ToString();

            calFrom.VisibleDate = booking.DateFrom;
            calFrom.SelectedDate = booking.DateFrom;

            for (int i = BookingSessionManager.DEF_MIN_NUM_OF_NIGHTS; i <= BookingSessionManager.DEF_MAX_NUM_OF_NIGHTS; ++i)
            {
                this.ddlNumOfNights.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }

            this.ddlNumOfNights.SelectedValue = ((booking.DateTo - booking.DateFrom).Days + 1).ToString();

            int capMin = accommodation.CapacityMin.HasValue ? accommodation.CapacityMin.Value : 1;
            int capMax = accommodation.CapacityMax.HasValue ? accommodation.CapacityMax.Value : 1;

            for (int i = capMin; i <= capMax; ++i)
            {
                this.ddlNumOfPersons.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }

            ddlNumOfPersons.SelectedValue = booking.NumOfPersons.ToString();

            for (int i = 0; i <= BookingSessionManager.DEF_MAX_NUM_OF_BABIES; ++i)
            {
                this.ddlNumOfBabies.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
            ddlNumOfBabies.SelectedValue = booking.NumOfBabies.ToString();

            lblCreateDate.Text = booking.DateCreated.ToShortDateString();
            lblAdminCreateName.Text = booking.AdminUserName != null ? booking.AdminUserName : String.Empty;
            lblLastUpdateDate.Text = booking.LastUpdateDate.HasValue ? booking.LastUpdateDate.Value.ToShortDateString() : String.Empty;

            lblUserFirstName.Text = booking.User.FirstName;
            lblUserLastName.Text = booking.User.LastName;
            lblUserEmail.Text = booking.User.Email;
            lblUserPhone.Text = booking.User.Phone;
            lblUserCountry.Text = booking.User.Country;
            lblUserCity.Text = booking.User.City;
            lblUserStreet.Text = booking.User.Street;

            hlBack.NavigateUrl = "/manage/bookingadmin.aspx?agencyId=" + accommodation.AgencyId.ToString() + "&accommid=" + accommodation.Id;
        }

        lblRetMsg.Text = " ";
    }
Exemplo n.º 14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int languageId = Common.GetLanguageId();
        dc = new UltimateDataContext();

        FetchAgency();

        ContactAgency1.AgencyEmail = agency.ContactEmail;
        ContactAgency1.AgencyName = agency.Name;

        if (!IsPostBack)
        {
            this.Title = String.Format(Resources.placeberry.Agency_Title, agency.Name);
            ltlAdress.Text = String.Format("{0}, {1}, {2}", agency.Address, agency.City, agency.Country);
            ltlAgencyTitle.Text = agency.Name;
            ltlEmail.Text = agency.ContactEmail;
            ltlPhones.Text = agency.ContactPhone;

            string agencyUrl = string.Empty;
            var agencyUrlTag = agency.AgencyUrlTags.SingleOrDefault();
            if (agencyUrlTag == null)
            {
                agencyUrl = "/Agency.aspx?id=" + agency.Id;
            }
            else
            {
                agencyUrl = Common.GenerateAgencyUrl(agencyUrlTag.UrlTag);
            }
            aAgencyLogo.HRef = agencyUrl;
            aAgencyName.HRef = agencyUrl;

            aAgencyName.InnerText = agency.Name;

            if (agency.AgencyDescriptions.Any())
            {
                var opisi = agency.AgencyDescriptions;
                ltlDescription.Text = opisi.Where(i => i.LanguageId == languageId).Select(i => i.Description).SingleOrDefault()
                    ?? opisi.Where(i => i.LanguageId == agency.LangaugeId).Select(i => i.Description).SingleOrDefault()
                    ?? opisi.Take(1).Select(i => i.Description).SingleOrDefault();
            }
            else
            {
                ltlDescription.Text = string.Empty;
            }

            if (agency.Image != null)
            {
                imgLogo.Src = "/thumb.aspx?src=" + agency.Image.Src + "&mw=185&mh=160&crop=1";
                imgLogo.Alt = agency.Image.Alt;
            }
            else
            {
                imgLogo.Src = "/resources/noimg.jpg";
                imgLogo.Alt = "";
            }
            aWebsite.HRef = agency.UrlWebsite ?? "#";
            aWebsite.InnerText = agency.UrlWebsite ?? string.Empty;

            RefeshAgencyAds();
        }
    }
Exemplo n.º 15
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        Validate();
        if (IsValid)
        {
            ccJoin.ValidateCaptcha(tbxCaptcha.Text);
            if (!ccJoin.UserValidated)
            {
                ltlCaptchaError.Visible = true;
                return;
            }

            string username = tbxUserName.Text.Trim();
            string password = tbxPassword.Text.Trim();
            string email = tbxEmail.Text.Trim().ToLower();

            //Ako postoji NEAKTIVIRANI korisnik s istim korisničkim imenom/emailom pobriši ga, da bezveze ne baca duplicate email grešku
            using (UltimateDataContext dc = new UltimateDataContext())
            {
                var user = (from p in dc.PlaceberryUsers
                            where   p.aspnet_User.aspnet_Membership.LoweredEmail == email &&
                                    p.aspnet_User.aspnet_Membership.IsApproved == false &&
                                    p.ActivationKey != null
                            select p).SingleOrDefault();
                if (user != null)
                {
                    Membership.DeleteUser(user.aspnet_User.UserName);
                }
            }

            MembershipCreateStatus status;
            MembershipUser newuser = Membership.CreateUser(username, password, email, null, null, false, Guid.NewGuid(), out status);

            switch (status)
            {
                case MembershipCreateStatus.DuplicateEmail:
                    ltlStatusErrorMessage.Text = status.ToString();
                    break;
                case MembershipCreateStatus.DuplicateProviderUserKey:
                    ltlStatusErrorMessage.Text = status.ToString();
                    break;
                case MembershipCreateStatus.DuplicateUserName:
                    ltlStatusErrorMessage.Text = status.ToString();
                    break;
                case MembershipCreateStatus.InvalidAnswer:
                    ltlStatusErrorMessage.Text = status.ToString();
                    break;
                case MembershipCreateStatus.InvalidEmail:
                    ltlStatusErrorMessage.Text = status.ToString();
                    break;
                case MembershipCreateStatus.InvalidPassword:
                    ltlStatusErrorMessage.Text = status.ToString();
                    break;
                case MembershipCreateStatus.InvalidProviderUserKey:
                    ltlStatusErrorMessage.Text = status.ToString();
                    break;
                case MembershipCreateStatus.InvalidQuestion:
                    ltlStatusErrorMessage.Text = status.ToString();
                    break;
                case MembershipCreateStatus.InvalidUserName:
                    ltlStatusErrorMessage.Text = status.ToString();
                    break;
                case MembershipCreateStatus.ProviderError:
                    ltlStatusErrorMessage.Text = status.ToString();
                    break;
                case MembershipCreateStatus.UserRejected:
                    ltlStatusErrorMessage.Text = status.ToString();
                    break;
                case MembershipCreateStatus.Success:
                    CreatePlaceberryUser(newuser);
                    ltlStatusErrorMessage.Text = "Uspješno ste se registirali, na email vam trebaju stići podaci za registraciju";
                    break;
                default:
                    break;
            }
        }
    }
Exemplo n.º 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            UltimateDataContext dc = new UltimateDataContext();
            Accommodation accommodation;

            int advertId = 0;
            int accommId = 0;

            // booking ce se moc pokretati i preko oglasa i preko agencije (accommodationid)
            if (Int32.TryParse(Request.QueryString["advertid"], out advertId))
            {
                GetAdvertResult advert = dc.GetAdvert(advertId).Single<GetAdvertResult>();

                // nisam siguran da je ovo dobar uvjet!
                if (advert != null && advert.PlaceberryAdvert && advert.AccommodationId.HasValue)
                {
                    accommId = advert.AccommodationId.Value;
                }
            }
            else
            {
                Int32.TryParse(Request.QueryString["accommid"], out accommId);
            }

            if (accommId == 0)
            {
                Response.Redirect("/");
            }

            accommodation = (from a in dc.Accommodations
                             where a.Id == accommId
                             select a).SingleOrDefault();

            if (accommodation == null)
            {
                Response.Redirect("/");
            }

            lblAgencyName.Text = accommodation.Agency.Name == null ? string.Empty : accommodation.Agency.Name;
            lblAccommName.Text = accommodation.Name == null ? string.Empty : accommodation.Name;

            int capMin = accommodation.CapacityMin.HasValue ? accommodation.CapacityMin.Value : 1;
            int capMax = accommodation.CapacityMax.HasValue ? accommodation.CapacityMax.Value : 1;

            for (int i = capMin; i <= capMax; ++i)
            {
                this.ddlNumOfPersons.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }

            for (int i = 0; i <= BookingSessionManager.DEF_MAX_NUM_OF_BABIES; ++i)
            {
                this.ddlNumOfBabies.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }

            bool priceByPerson = false; // ovo se mora nekako postaviti
            _booking = new BookingSessionManager(accommodation.Id, accommodation.Name, accommodation.AgencyId, priceByPerson, true);

            // ukoliko admin kreira i ovdje booking takoder ga spremiti
            if (User.IsInRole("Administrators") || accommodation.Agency.PlaceberryUser.aspnet_User.UserName == User.Identity.Name)
            {
                _booking.SetAdminUserName(User.Identity.Name);
            }

            HttpContext.Current.Session[BookingSessionManager.BOOKING_SESSION_NAME] = _booking;
        }
    }
Exemplo n.º 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        dc = new UltimateDataContext();

        string action = Request["action"];
        action = action == null ? string.Empty : action.ToLower();

        switch (action)
        {
            case "editaccomm":
                EditAccomm();
                break;
            case "newaccomm":
                NewAccomm();
                break;
            case "editimages":
                EditImages();
                break;
            case "editprices":
                EditPrices();
                break;
            case "entrysuccess":
                ReadAccomm();
                ltlStatus.Text = (string)HttpContext.Current.Items["statusmessage"];
                break;
            default:
                ReadAccomm();
                break;
        }

        if (!IsPostBack && accommodation != null)
        {
            aAccomm.HRef = String.Format("/manage/accommodation.aspx?accommid={0}", accommodation.Id);
            aAccomm.InnerText = accommodation.Name;
        }
    }
Exemplo n.º 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        dc = new UltimateDataContext();

        string action = Request.QueryString["action"] ?? string.Empty;

        switch (action)
        {
            case "newentry":
                NewEntry();
                break;
            case "editentry":
                EditEntry();
                break;
            default:
                EditEntry();
                break;
        }

        if (!IsPostBack)
        {
            RefreshUltimateTableGrid();

            var querystring = HttpUtility.ParseQueryString(Request.Url.Query);
            querystring["action"] = "newentry";
            aNewUltimate.HRef = String.Format("/manage/ultimatetable.aspx?{0}", querystring.ToString());
        }

        GetShowStatusMessage();
    }
Exemplo n.º 19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string action = Request["action"];
        action = action == null ? string.Empty : action.ToLower();

        dc = new UltimateDataContext();

        switch (action)
        {
            case "newagency":
                NewAgency();
                break;
            case "editagency":
                EditAgency();
                break;
            case "entrysuccess":
                ReadAgency();
                ltlStatus.Text = (string)HttpContext.Current.Items["statusmessage"];
                break;
            default:
                ReadAgency();
                break;
        }
    }
Exemplo n.º 20
0
    public IEnumerable SuggestCity(string term, int maxresults)
    {
        IEnumerable cities = null;
        term = term.ToLower();

        using (UltimateDataContext dc = new UltimateDataContext())
        {
            cities = (from p in dc.UltimateTables
                      where p.UltimateTableObjectType.Id == (int)ObjectType.CITY && p.Title.ToLower().Contains(term)
                      orderby p.Title ascending
                      select new
                      {
                          Id = p.Id,
                          Title = p.Title
                      }).Take(maxresults).ToList();
        }

        return cities;
    }
Exemplo n.º 21
0
 public static string GetAutoRegex(string term, int languageid)
 {
     string regex = string.Empty;
     using (UltimateDataContext dc = new UltimateDataContext())
     {
         dc.GetAutoRegex(term, languageid, ref regex);
     }
     return regex;
 }
Exemplo n.º 22
0
    public static IEnumerable GetAutoParentSuggestions(string term, int childtypeid, int maxresults)
    {
        IEnumerable results = null;

        if (childtypeid > 0)
        {
            ObjectType childtype = (ObjectType)childtypeid;

            using (UltimateDataContext dc = new UltimateDataContext())
            {
                IQueryable<UltimateTable> query = null;
                bool noquery = false;
                switch (childtype)
                {
                    case ObjectType.ISLAND:
                        query = from p in dc.UltimateTables
                                where (p.ObjectTypeId == (int)ObjectType.SUBREGION ||
                                         p.ObjectTypeId == (int)ObjectType.REGION) && p.Title.Contains(term)
                                select p;
                        break;
                    case ObjectType.CITY:
                        query = from p in dc.UltimateTables
                                where (p.ObjectTypeId == (int)ObjectType.SUBREGION ||
                                         p.ObjectTypeId == (int)ObjectType.REGION ||
                                         p.ObjectTypeId == (int)ObjectType.ISLAND) && p.Title.Contains(term)
                                select p;
                        break;
                    case ObjectType.COUNTRY:
                        noquery = true;
                        break;
                    case ObjectType.REGION:
                        query = from p in dc.UltimateTables
                                where p.ObjectTypeId == (int)ObjectType.COUNTRY && p.Title.Contains(term)
                                select p;
                        break;
                    case ObjectType.SUBREGION:
                        query = from p in dc.UltimateTables
                                where p.ObjectTypeId == (int)ObjectType.REGION && p.Title.Contains(term)
                                select p;
                        break;
                    default:
                        noquery = true;
                        break;
                }
                if (!noquery)
                {
                    results = (from p in query
                               orderby p.Title ascending
                               select new
                               {
                                   Id = p.Id,
                                   Title = String.Format("{0} [id={1}, type={2}]", p.Title, p.Id, p.UltimateTableObjectType.Code.ToLower())
                               }).Take(maxresults).ToList();
                }
            }
        }
        return results;
    }
Exemplo n.º 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int languageId = Common.GetLanguageId();
        string termTag = Request.QueryString["tag"] ?? string.Empty;
        termTag = termTag.Split('/').LastOrDefault();

        Repeater topAdverts = TopAdverts.Adverts;

        if (!string.IsNullOrEmpty(termTag))
        {
            using (UltimateDataContext dc = new UltimateDataContext())
            {

                var query = (from p in dc.UltimateTableUrlTags
                             where p.UrlTag == termTag && p.LanguageId == languageId
                             select new
                             {
                                 Id = p.UltimateTable.Id,
                                 Title = p.UltimateTable.Title,
                                 UrlTag = p.UrlTag
                             }).Distinct();

                if (query.Any())
                {
                    var term = query.First();

                    string termTitle = (from p in dc.UltimateTableTranslations
                                        where p.UltimateTableId == term.Id && p.Active == true && p.LanguageId == languageId
                                        select p.Title).SingleOrDefault() ?? term.Title;

                    ltlCurrentTerm.Text = termTitle;

                    this.Title = String.Format(Resources.placeberry.Directory_TitleFormat, termTitle);

                    string termDesc = (from p in dc.UltimateTableInfos
                                       where p.UltimateTableId == term.Id && p.LanguageId == languageId
                                       select p.WikiDescription).SingleOrDefault() ?? string.Empty;

                    if (!string.IsNullOrEmpty(termDesc))
                    {
                        termDesc = termDesc.Replace("\n", "<br />");
                        ltlDescription.Text = termDesc;
                        pnlDescription.Visible = true;
                    }
                    else
                    {
                        pnlDescription.Visible = false;
                    }

                    //BREADCRUMBS
                    //dodajemo root
                    breadcrumbs.Add(new UltimateTerm() { Id = 0, Title = "dir", UrlLink = Resources.placeberry.URL_Directory, UrlTag = Resources.placeberry.URL_Directory });

                    //dodajemo ostale elemente
                    breadcrumbs.AddRange(from p in dc.GetParents(null, term.Id, languageId)
                                         where p.ObjectTypeGroupCode != null && p.ObjectTypeGroupCode == "GEO"
                                         select new UltimateTerm()
                                         {
                                             Id = p.ParentId,
                                             Title = p.ParentTitle,
                                             UrlTag = p.UrlTag,
                                             UrlLink = string.Empty
                                         });

                    //gradimo linkove
                    for (int i = 1; i < breadcrumbs.Count; i++)
                    {
                        breadcrumbs[i].UrlLink = breadcrumbs[i - 1].UrlLink + "/" + breadcrumbs[i].UrlTag;
                    }

                    //dodajemo trenutni pojam zato što GetParents vrati samo roditelje, a ne i trenutni
                    var currTerm = new UltimateTerm() { Id = term.Id, Title = termTitle, UrlTag = term.UrlTag };
                    var previousTerm = breadcrumbs.Last();
                    breadcrumbs.Add(currTerm);
                    currTerm.UrlLink = previousTerm.UrlLink + "/" + currTerm.UrlTag;

                    repBreadcrumbs.DataSource = breadcrumbs;
                    repBreadcrumbs.DataBind();

                    //CHILDREN
                    var children = from p in dc.UltimateTableRelations
                                   where p.ParentId == term.Id && p.Child.UltimateTableObjectType.GroupCode == "GEO"
                                   select p.Child;

                    var childrenTranslated = from p in children
                                             join q in dc.UltimateTableTranslations on p equals q.UltimateTable into trans
                                             join t in dc.UltimateTableUrlTags on p equals t.UltimateTable into tags
                                             from r in trans.Where(i => i.LanguageId == languageId && i.Active == true).DefaultIfEmpty()
                                             from s in tags.Where(i => i.LanguageId == languageId).DefaultIfEmpty()
                                             select new
                                             {
                                                 Id = p.Id,
                                                 Title = r != null ? r.Title : p.Title,
                                                 UrlLink = String.Format("{0}/{1}", currTerm.UrlLink, s.UrlTag)
                                             };

                    if (childrenTranslated.Any())
                    {
                        repChildren.DataSource = childrenTranslated;
                        repChildren.DataBind();
                    }
                    else
                    {
                        repChildren.Visible = false;
                    }

                    string queryMessage = string.Empty;
                    topAdverts.DataSource = Placeberry.DAL.GetResults.Execute(termTitle, languageId, 5, 0, 5, 0, out queryMessage);
                    topAdverts.DataBind();

                    aCurrentTerm.HRef = String.Format("/{0}?q={1}", Resources.placeberry.General_VacationUrl, termTitle);
                    aCurrentTerm.InnerText = String.Format(Resources.placeberry.Directory_SearchCurrentTerm, termTitle);
                    aCurrentTerm.Visible = true;

                    string keywords = string.Join(", ", breadcrumbs.Skip(1).Select(i => i.Title).ToArray());

                    HtmlMeta metaKeywords = new HtmlMeta() { Name = "keywords", Content = string.Empty };
                    HtmlMeta metaDescription = new HtmlMeta() { Name = "description", Content = string.Empty };

                    metaDescription.Content = String.Format(Resources.placeberry.Directory_MetaDescription, termTitle);
                    metaKeywords.Content = String.Format(Resources.placeberry.Directory_MetaKeywords, keywords);

                    Header.Controls.Add(metaDescription);
                    Header.Controls.Add(metaKeywords);
                }
                else
                {
                    //ERROR ne postoji taj pojam u direktoriju
                }

            }
        }
        else
        {
            using (UltimateDataContext dc = new UltimateDataContext())
            {
                var countries = from p in dc.UltimateTables
                                where p.Active == true && p.UltimateTableObjectType.Code == "COUNTRY"
                                select p;

                var countriesTranslated = from p in countries
                                          join q in dc.UltimateTableTranslations on p equals q.UltimateTable into trans
                                          join t in dc.UltimateTableUrlTags on p equals t.UltimateTable into tags
                                          from r in trans.Where(i => i.LanguageId == languageId && i.Active == true).DefaultIfEmpty()
                                          from s in tags.Where(i => i.LanguageId == languageId).DefaultIfEmpty()
                                          select new
                                          {
                                              Id = p.Id,
                                              Title = r != null ? r.Title : p.Title,
                                              UrlLink = String.Format("{0}/{1}", Resources.placeberry.URL_Directory, s.UrlTag)
                                          };

                if (countriesTranslated.Any())
                {

                    repChildren.DataSource = countriesTranslated;
                    repChildren.DataBind();
                }

                ltlTopAdsText.Visible = false;
                topAdverts.Visible = false;

                HtmlMeta metaKeywords = new HtmlMeta() { Name = "keywords", Content = string.Empty };
                HtmlMeta metaDescription = new HtmlMeta() { Name = "description", Content = string.Empty };

                metaDescription.Content = String.Format(Resources.placeberry.Directory_MetaDescription, "smještaj");
                metaKeywords.Content = String.Format(Resources.placeberry.Directory_MetaKeywords, "smještaj");

                Header.Controls.Add(metaDescription);
                Header.Controls.Add(metaKeywords);

            }
        }
    }
Exemplo n.º 24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            phMainContent.Visible = true;
            phLoadError.Visible = false;

            UltimateDataContext dc = new UltimateDataContext();
            Accommodation accommodation;

            int accommId = 0;

            if(!Int32.TryParse(Request.QueryString["accommid"], out accommId))
            {
                phMainContent.Visible = false;
                phLoadError.Visible = true;
                lblLoadErrorMsg.Text = ERR_MSG_WRONG_PARAMETARS;
                return;
            }

            accommodation = (from a in dc.Accommodations
                             where a.Id == accommId
                             select a).SingleOrDefault();

            if (accommodation == null)
            {
                phMainContent.Visible = false;
                phLoadError.Visible = true;
                lblLoadErrorMsg.Text = ERR_MSG_ACCOMMODATION_NOT_FOUND;
                return;
            }

            // kako je ovo booking sa admina provjeriti prava
            bool isAdmin = User.IsInRole("Administrators");

            UltimateDC.Agency agency = (from p in dc.Agencies
                        where p.Id == accommodation.AgencyId && (isAdmin || p.PlaceberryUser.aspnet_User.UserName == User.Identity.Name) // svaka agencija ima samo jednog usera pa ako nije admin provjeriti dali je user od pripadajuce agencije
                       select p).SingleOrDefault();

            if (agency == null)
            {
                phMainContent.Visible = hlReturn.Visible = false;
                phLoadError.Visible = true;
                lblLoadErrorMsg.Text = ERR_MSG_ACCESS_NOT_ALLOWED_OR_AGENCY_NOT_FOUND;
                return;
            }

            lblAgencyName.Text = accommodation.Agency.Name == null ? string.Empty : accommodation.Agency.Name;
            lblAccommName.Text = accommodation.Name == null ? string.Empty : accommodation.Name;

            for (int i = BookingSessionManager.DEF_MIN_NUM_OF_NIGHTS; i <= BookingSessionManager.DEF_MAX_NUM_OF_NIGHTS; ++i)
            {
                this.ddlNumOfNights.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }

            int capMin = accommodation.CapacityMin.HasValue ? accommodation.CapacityMin.Value : 1;
            int capMax = accommodation.CapacityMax.HasValue ? accommodation.CapacityMax.Value : 1;

            for (int i = capMin; i <= capMax; ++i)
            {
                this.ddlNumOfPersons.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }

            for (int i = 0; i <= BookingSessionManager.DEF_MAX_NUM_OF_BABIES; ++i)
            {
                this.ddlNumOfBabies.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }

            this.lblPriceSum.Text = "0";
            this.lblNumOfPersons.Text = ddlNumOfPersons.SelectedValue;
            this.lblNumOfBabies.Text = ddlNumOfBabies.SelectedValue;
            this.phPriceByDay.Visible = false;
            this.phNoPrices.Visible = false;

            // OVO JOS DODATI
            hlReturn.NavigateUrl = "bookingadmin.aspx?agencyId=" + agency.Id + "&accommid=" + accommodation.Id;

            bool priceByPerson = false; // ovo se mora nekako postaviti
            _bookingSession = new BookingSessionManager(accommodation.Id, accommodation.Name, agency.Id, priceByPerson, false);    // stavi checkmembership na false jer admin radi rezervaciju za nekoga ko moze ili ne mora bit clan placeberrya

            _bookingSession.SetAdminUserName(User.Identity.Name);  // spremiti admina koji kreira booking

            HttpContext.Current.Session[BookingSessionManager.BOOKING_SESSION_NAME] = _bookingSession;
        }
    }
Exemplo n.º 25
0
    private void CreatePlaceberryUser(MembershipUser user)
    {
        using (UltimateDataContext dc = new UltimateDataContext())
        {
            PlaceberryUser newuser = new PlaceberryUser();
            newuser.UserId = (Guid)user.ProviderUserKey;
            newuser.ActivationKey = Guid.NewGuid();

            dc.PlaceberryUsers.InsertOnSubmit(newuser);
            dc.SubmitChanges();

            SendActivationEmailToUser(user, newuser.ActivationKey.Value.ToString());
        }
    }
Exemplo n.º 26
0
    public static IEnumerable GetAutoNotGeoChildSuggestions(string term, int parentid, int maxresults)
    {
        IEnumerable results = null;

        using (UltimateDataContext dc = new UltimateDataContext())
        {
            var parent = (from p in dc.UltimateTables
                          where p.Id == parentid
                          select p).SingleOrDefault();

            var children = from p in dc.UltimateTableRelations
                           where p.Parent == parent
                           select p.Child;

            var query = from p in dc.UltimateTables
                        where !children.Contains(p)
                                && p != parent
                                && p.Title.Contains(term)
                        select p;

            if (parent.UltimateTableObjectType.GroupCode == "GEO")
            {
                query = from p in query
                        where p.UltimateTableObjectType.GroupCode != "GEO" || p.UltimateTableObjectType.GroupCode == null
                        select p;
            }

            results = (from p in query
                       orderby p.Title ascending
                       select new
                       {
                           Id = p.Id,
                           Title = String.Format("{0} [id={1}, type={2}]", p.Title, p.Id, p.UltimateTableObjectType.Code.ToLower())
                       }).Take(maxresults).ToList();
        }

        return results;
    }
Exemplo n.º 27
0
    public static IEnumerable GetUltimateTableSearchSuggestions(string term, int maxresults)
    {
        IEnumerable results = null;
        using (UltimateDataContext dc = new UltimateDataContext())
        {
            results = (from p in dc.UltimateTables
                       where p.Title.Contains(term)
                       orderby p.Title ascending
                       select new
                       {
                           Id = p.Id,
                           Title = String.Format("{0} [id={1}, type={2}]", p.Title, p.Id, p.UltimateTableObjectType.Code.ToLower()),
                           Url = String.Format("/manage/ultimatetable.aspx?ultimateid={0}", p.Id)
                       }).Take(maxresults).ToList();
        }

        return results;
    }
Exemplo n.º 28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        dc = new UltimateDataContext();

        if (!IsPostBack)
        {
            var countrys = from p in dc.UltimateTables
                           where (ObjectType)p.ObjectTypeId == ObjectType.COUNTRY
                           orderby p.Title ascending
                           select p.Title;

            cbxCountry.DataSource = countrys;
            cbxCountry.DataBind();

            var languages = (from p in dc.Languages
                             orderby p.Title ascending
                             select new { Id = p.Id, Title = p.Title }).ToList();
            languages.Insert(0, new { Id = 0, Title = string.Empty });

            ddlLanguage.DataSource = languages;
            ddlLanguage.DataTextField = "Title";
            ddlLanguage.DataValueField = "Id";
            ddlLanguage.DataBind();

            if (string.IsNullOrEmpty(Request["id"]))
            {
                int agencyId;
                if (!int.TryParse(Request["agencyId"], out agencyId))
                    Response.Redirect("/Manage/Customer.aspx");

                litNaslov.Text = "Novi zapis";
            }
            else
            {
                litNaslov.Text = "Uređivanje zapisa";

                int advertId;
                if (!int.TryParse(Request["id"], out advertId))
                    Response.Redirect("/Manage/Customer.aspx");

                LoadAdvert(advertId);
            }
        }
        else
        {
            Validate();
        }
    }
Exemplo n.º 29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        dc = new UltimateDataContext();

        FetchAccommodation();

        ContactAgency1.AgencyEmail = accommodation.Agency.ContactEmail;
        ContactAgency1.AgencyName = accommodation.Agency.Name;

        if (!IsPostBack)
        {
            SetJavascriptVariables();

            int languageId = Common.GetLanguageId();
            var agency = accommodation.Agency;

            this.Title = String.Format(Resources.placeberry.AgencyListing_Title, agency.Name + " - " + accommodation.Name);

            string agencyUrl = string.Empty;
            var agencyUrlTag = agency.AgencyUrlTags.SingleOrDefault();
            if (agencyUrlTag == null)
            {
                agencyUrl = "/Agency.aspx?id=" + agency.Id;
            }
            else
            {
                agencyUrl = Common.GenerateAgencyUrl(agencyUrlTag.UrlTag);
            }
            aAgencyLogo.HRef = agencyUrl;
            aAgencyName.HRef = agencyUrl;

            aAgencyName.InnerText = agency.Name;
            ltlAgencyAdress.Text = String.Format("{0}, {1}, {2}", agency.Address, agency.City, agency.Country);
            ltlAgencyEmail.Text = agency.ContactEmail;
            ltlAgencyPhones.Text = agency.ContactPhone;
            if (agency.Image != null)
            {
                imgAgencyLogo.Src = "/thumb.aspx?src=" + agency.Image.Src + "&mw=185&mh=160&crop=1";
                imgAgencyLogo.Alt = agency.Image.Alt;
            }
            else
            {
                imgAgencyLogo.Src = "/resources/noimg.jpg";
                imgAgencyLogo.Alt = "";
            }
            aAgencyWebsite.HRef = agency.UrlWebsite ?? "#";
            aAgencyWebsite.InnerText = agency.UrlWebsite ?? string.Empty;

            ltlListingTitle.Text = accommodation.Name;
            ltlListingType.Text = dc.GetTraslation(accommodation.TypeId, languageId);
            ltlListingCapacity.Text = Common.FormatCapacity(accommodation.CapacityMin, accommodation.CapacityMax);

            var descriptions = from p in accommodation.AccommodationDescriptions
                               where p.LanguageId == languageId || p.LanguageId == accommodation.Agency.LangaugeId
                               select p;
            string translation = descriptions.Where(i => i.LanguageId == languageId).Select(i => i.Description).SingleOrDefault() ?? descriptions.Where(i => i.LanguageId == agency.LangaugeId).Select(i => i.Description).SingleOrDefault();
            ltlListingDescription.Text = translation ?? string.Empty;

            string location = dc.GetTraslation(accommodation.AccommodationCity.UltimateTableId, languageId);
            var parents = (from p in dc.GetParents(null, accommodation.AccommodationCity.UltimateTableId, languageId)
                           orderby p.Lvl
                           select p.ParentTitle).ToArray();
            if (parents.Any())
            {
                location += ", " + string.Join(", ", parents);
            }
            ltlListingLocation.Text = location;

            RefeshGallery();
            RefreshPrices();
        }
    }
Exemplo n.º 30
0
    public static IEnumerable GetAutoChildSuggestions(string term, int parentid, int parenttypeid, int maxresults)
    {
        IEnumerable results = null;

        if (parenttypeid > 0)
        {
            ObjectType parentype = (ObjectType)parenttypeid;

            using (UltimateDataContext dc = new UltimateDataContext())
            {
                IQueryable<UltimateTable> query = null;
                bool noquery = false;
                switch (parentype)
                {
                    case ObjectType.ISLAND:
                        query = from p in dc.UltimateTables
                                where p.ObjectTypeId == (int)ObjectType.CITY && p.Title.Contains(term)
                                select p;
                        break;
                    case ObjectType.CITY:
                        noquery = true;
                        break;
                    case ObjectType.COUNTRY:
                        query = from p in dc.UltimateTables
                                where (p.ObjectTypeId == (int)ObjectType.REGION ||
                                    p.ObjectTypeId == (int)ObjectType.SUBREGION) && p.Title.Contains(term)
                                select p;
                        break;
                    case ObjectType.REGION:
                        query = from p in dc.UltimateTables
                                where (p.ObjectTypeId == (int)ObjectType.SUBREGION ||
                                    p.ObjectTypeId == (int)ObjectType.ISLAND ||
                                    p.ObjectTypeId == (int)ObjectType.CITY) && p.Title.Contains(term)
                                select p;
                        break;
                    case ObjectType.SUBREGION:
                        query = from p in dc.UltimateTables
                                where (p.ObjectTypeId == (int)ObjectType.ISLAND ||
                                    p.ObjectTypeId == (int)ObjectType.CITY) && p.Title.Contains(term)
                                select p;
                        break;
                    default:
                        noquery = true;
                        break;
                }
                if (!noquery)
                {
                    var check = from p in dc.UltimateTableRelations
                                where p.Parent.UltimateTableObjectType.GroupCode == "GEO"
                                select p.Child;

                    var children = from p in dc.UltimateTableRelations
                                   where p.ParentId == parentid && p.Child.UltimateTableObjectType.GroupCode == "GEO"
                                   select p.Child;

                    results = (from p in query
                               where !check.Contains(p) && !children.Contains(p)
                               orderby p.Title ascending
                               select new
                               {
                                   Id = p.Id,
                                   Title = String.Format("{0} [id={1}, type={2}]", p.Title, p.Id, p.UltimateTableObjectType.Code.ToLower())
                               }).Take(maxresults).ToList();
                }

            }
        }
        return results;
    }