Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/ASP.NET/CS/HotelBooking/App_Code/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/ASP.NET/CS/HotelBooking/App_Code/Utils.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DevExpress.Web.ASPxEditors;

public static class Utils {
    public const int GridImageSize = 200;
    public const int OrderImageSize = 260;
    public const int PopupImageSize = 600;

    public static string GetOrderFormUrl(object hotel) {
        string title = (hotel as Hotel).Title;
        return string.Format("Order.aspx?h={0}", title.Replace(" ", "_").Replace("&", "AMP"));
    }
    public static void ValidateCheckInDate(ValidationEventArgs e) {
        if((DateTime)e.Value < DateTime.Now) {
            e.IsValid = false;
            e.ErrorText = "Date should be later then current";
        }
    }
    public static void ValidateCheckOutDate(DateTime checkInDate, ValidationEventArgs e) {
        if((DateTime)e.Value < checkInDate) {
            e.IsValid = false;
            e.ErrorText = "Checkout date should be later then checkin date";
        }
    }
    public static string GetImageUrl(string url, int size) {
        return string.Format("Thumb.ashx?i={0}&size={1}", url, size);
    }
    public static string GetPageTitle(string currentTitle) {
        if(string.IsNullOrEmpty(currentTitle))
            return "Hotel Booking - Powered by DevExpres Inc";
        return string.Format("{0} - Hotel Booking - Powered by DevExpres Inc", HttpUtility.HtmlEncode(currentTitle));
    }
    public static void SetDefaultDateEditValues(ASPxDateEdit deCheckIn, ASPxDateEdit deCheckOut) {
        deCheckIn.Value = DateTime.Now.AddDays(3);
        deCheckOut.Value = DateTime.Now.AddDays(6);
        deCheckIn.MinDate = DateTime.Now;
        deCheckOut.MinDate = DateTime.Now.AddDays(1);
    }
}