protected void btnGiveFeedback_Click(object sender, EventArgs e)
    {
        //Recording the feedback when user clicked to add feedback
        pnlFeedback.Visible = false;
        //Retrieving the clicked feedback panel
        ItemBooking item   = (ItemBooking)Session["retrieve"];
        Review      review = new Review();

        //Receiving the written comment and rating to add in the database
        review.Date         = DateTime.Now;
        review.Time         = DateTime.Now;
        review.Feedback     = tbxComment.Text;
        review.Rating       = Convert.ToInt32(tbxRatings.Text);
        review.ReportStatus = ddlHotel.SelectedItem.Text;
        review.HotelID      = item.RoomID.Hotel;
        Customer c = (Customer)Session["user"];

        review.CustEmail = c;
        //Adding feedback with method
        int add = ReviewDB.addReviewRoom(review);

        lbladded.Visible = true;
        //Displaying message to inform user
        lbladded.Text = "Feedback submitted successfully! Thanks for your feedback................";
    }
Exemplo n.º 2
0
        public BookingResponse ReleaseItem(BookingDetailInfor bookingDetailInfor)
        {
            using (StageBitzDB dataContext = new StageBitzDB())
            {
                InventoryBL     inventoryBL     = new InventoryBL(dataContext);
                ItemBooking     itemBooking     = inventoryBL.GetItemBooking(bookingDetailInfor.ItemBookingId);
                BookingResponse bookingResponse = new BookingResponse();
                if (itemBooking != null)
                {
                    if (itemBooking != null &&
                        (!(Utils.IsCompanyInventoryAdmin(itemBooking.Item.CompanyId.Value, bookingDetailInfor.UserId) ||
                           Utils.IsCompanyInventoryStaffMember(itemBooking.Item.CompanyId.Value, bookingDetailInfor.UserId, itemBooking.Item.LocationId, dataContext))))
                    {
                        bookingResponse.Status    = "NOTOK";
                        bookingResponse.ErrorCode = (int)ErrorCodes.NoEditPermissionForInventory;
                        bookingResponse.Message   = "Could not release the Item.";
                        return(bookingResponse);
                    }

                    bool isSuccess = inventoryBL.RemoveInUseItemFromItemBrief(itemBooking.RelatedId, bookingDetailInfor.UserId);
                    bookingResponse.Status = isSuccess ? "OK" : "NOTOK";
                }
                else
                {
                    bookingResponse.Status = "NOTOK";
                }

                return(bookingResponse);
            }
        }
 protected void gvHistory_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     lbladded.Visible    = false;
     gvRoom.Visible      = false;
     pnlFeedback.Visible = false;
     //show the full details of selected role
     if (e.CommandName == "Select")
     {
         List <Booking> bookingList = (List <Booking>)Session["History"];
         Booking        book        = bookingList[gvHistory.PageIndex * gvHistory.PageSize + Convert.ToInt32(e.CommandArgument)];
         //Checking room item booking to display
         List <ItemBooking> itemList = ItemBookingDB.getAllRoomItemBooking();
         List <ItemBooking> item     = new List <ItemBooking>();
         //Showing each item that is under the selected booking
         foreach (ItemBooking it in itemList)
         {
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 gvRoom.Visible = true;
                 ItemBooking room = it;
                 item.Add(room);
             }
         }
         //Not showing rooms when there's no rooms under selected booking
         if (item.Count > 0)
         {
             gvRoom.DataSource = item;
             gvRoom.DataBind();
             Session["OldRoom"] = item;
         }
         List <ItemBooking> tList   = ItemBookingDB.getAllTicketItemBooking();
         List <ItemBooking> tickets = new List <ItemBooking>();
         foreach (ItemBooking it in tList)
         {
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 dlTicket.Visible = true;
                 ItemBooking ticket = it;
                 tickets.Add(ticket);
                 gvTicket.DataSource = tickets;
                 gvTicket.DataBind();
                 Session["OldTicket"] = tickets;
             }
         }
         List <ItemBooking> rList       = ItemBookingDB.getAllRestaurantItemBooking();
         List <ItemBooking> restaurants = new List <ItemBooking>();
         foreach (ItemBooking it in rList)
         {
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 dlRestaurant.Visible = true;
                 ItemBooking restaurant = it;
                 restaurants.Add(restaurant);
                 gvRestaurant.DataSource = restaurants;
                 gvRestaurant.DataBind();
                 Session["OldRestaurant"] = restaurants;
             }
         }
     }
 }
Exemplo n.º 4
0
        public ItemBriefDetails GetItemBriefDetails(ItemBriefRequestDetails itemBriefRequestDetails)
        {
            ItemBriefDetails itemBriefDetails = new Data.DataTypes.ItemBriefDetails();

            using (StageBitzDB dataContext = new StageBitzDB())
            {
                try
                {
                    ItemBriefBL itemBriefBL = new ItemBriefBL(dataContext);
                    ItemTypesBL itemTypesBL = new ItemTypesBL(dataContext);

                    Data.ItemBrief itemBrief = itemBriefBL.GetItemBrief(itemBriefRequestDetails.ItemBriefId);

                    int projectId = 0;
                    if (itemBrief != null)
                    {
                        projectId = itemBrief.ProjectId;
                    }

                    itemBriefDetails.CountryId = itemBriefBL.GetCountryIdByItemBriefId(itemBrief.ItemBriefId);

                    itemBriefDetails.ItemBriefInfo       = itemBriefBL.GetItemBriefInfoByItemBrief(itemBrief);
                    itemBriefDetails.IsReadOnly          = Support.IsReadOnlyRightsForProject(projectId, itemBriefRequestDetails.UserId);
                    itemBriefDetails.CanSeeBudgetSummary = Support.CanSeeBudgetSummary(itemBriefRequestDetails.UserId, projectId);
                    int itemTypeId = itemBriefRequestDetails.ItemTypeId.HasValue ?
                                     itemBriefRequestDetails.ItemTypeId.Value : itemBriefBL.GetItemBriefType(itemBriefRequestDetails.ItemBriefId).ItemTypeId;
                    itemBriefDetails.DisplayMarkUp   = itemTypesBL.GetItemTypeHTML(itemTypeId);
                    itemBriefDetails.ItemBriefValues = itemTypesBL.GetItemBriefFieldValues(itemBriefRequestDetails.ItemBriefId).Select(ibfv =>
                                                                                                                                       new ValuesInfo
                    {
                        Id            = ibfv.ItemBriefValueId,
                        FieldId       = ibfv.FieldId,
                        FieldOptionId = ibfv.FieldOptionId,
                        Value         = ibfv.Value
                    }).ToList();

                    int itemId = 0;
                    int userId = 0;

                    ItemBooking itemBooking = itemBriefBL.GetInUseItemBooking(itemBriefRequestDetails.ItemBriefId);
                    if (itemBooking != null)
                    {
                        itemId = itemBooking.ItemId;
                    }

                    userId = itemBriefRequestDetails.UserId;
                    ItemDetails itemDetails = itemTypesBL.GetItemDetails(itemId, itemBriefRequestDetails.ItemBriefId, userId, null, null, null);
                    if (itemDetails != null)
                    {
                        itemBriefDetails.ItemDetails = itemDetails;
                    }
                }
                catch (Exception ex)
                {
                    AgentErrorLog.HandleException(ex);
                }
                return(itemBriefDetails);
            }
        }
    protected void gvUpcoming_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        //Allowing access to service provider to update booking status
        lblCustomer.Visible = false;
        dlCustomer.Visible  = false;
        List <ItemBooking> itemList = (List <ItemBooking>)Session["Upcoming"];
        ItemBooking        item     = itemList[Convert.ToInt32(gvUpcoming.PageSize * gvUpcoming.PageIndex + e.RowIndex)];

        //Checking pending bookings to update status
        if (item.ItemBookingStatus == "Pending")
        {
            if (e.NewValues["ItemBookingStatus"].ToString() == "Pending" || e.NewValues["ItemBookingStatus"].ToString() == "Approved" || e.NewValues["ItemBookingStatus"].ToString() == "Rejected")
            {
                lblNoResult.Text     = "";
                gvUpcoming.EditIndex = -1;
                //Sending email with company email
                SmtpClient client = new SmtpClient("smtp.gmail.com");
                client.EnableSsl   = true;
                client.Credentials = new NetworkCredential("*****@*****.**", "smart-travel1005");
                MailMessage msg = new MailMessage("*****@*****.**", item.BookingID.CID.CustEmail);
                if (e.NewValues["ItemBookingStatus"].ToString() == "Approved")
                {
                    //Informing customer about approve booking
                    try
                    {
                        msg.Subject = "Your Booking has been confirmed";
                        msg.Body    = "Your reservation booking at " + item.RestaurantID.Name + " has been confirmed. Check out the updated status on our website. Your booking ID is " + item.BookingID.BookingID + "\r\n";
                        msg.Body   += "Thanks you for choosing SmartTravel";
                        client.Send(msg);
                        item.ItemBookingStatus = Convert.ToString(e.NewValues["ItemBookingStatus"]);
                        //updating item booking status into database
                        int add = ItemBookingDB.UpdateItemBooking(item);
                        bind();
                    }
                    //If email cannot be sent
                    catch (Exception er)
                    {
                        lblNoResult.Text = "Internet connection required: " + er.ToString();
                    }
                }
                //Informing customer about approve booking
                else if (e.NewValues["ItemBookingStatus"].ToString() == "Rejected")
                {
                    msg.Subject = "Your Booking has been rejected";
                    msg.Body    = "We're sorry to inform you that your reservation booking at " + item.RestaurantID.Name + " has been rejected. Check out the updated status on our website. Your booking ID is " + item.BookingID.BookingID + "\r\n";
                    msg.Body   += "Thanks you for choosing SmartTravel";
                    client.Send(msg);
                }
            }
            else
            {
                lblNoResult.Text = "Status can only be Pending, Approved or Rejected!";
            }
        }
        else
        {
            lblNoResult.Text = "Status can be changed only for the Pending Booking";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //if user hotel is null
        if (Session["userHotel"] == null)
        {
            Response.Redirect("LoginForm.aspx"); //brings to the loginform page
        }
        lblNoResult.Text    = "";
        lblFeedback.Visible = false;

        if (!IsPostBack)
        {
            //Displaying upcoming and past bookings
            lblCustomer.Visible = false;
            dlCustomer.Visible  = false;
            gvFeedback.Visible  = false;
            lblTitle.Text       = "Upcoming Booking";
            gvHistory.Visible   = false;
            //Getting current signed in user
            Hotel hotel = (Hotel)Session["userHotel"];
            //Getting booked rooms from database and display them
            List <ItemBooking> itemList = ItemBookingDB.getAllRoomItemBooking();
            List <ItemBooking> upcoming = new List <ItemBooking>();
            List <ItemBooking> history  = new List <ItemBooking>();
            foreach (ItemBooking it in itemList)
            {
                //Checking the date to show only the upcoming events
                if (it.RoomID.Hotel.OrgEmail == hotel.OrgEmail)
                {
                    if (it.StartDate > DateTime.Now && it.ItemBookingStatus != "Canceled")
                    {
                        ItemBooking item = it;
                        upcoming.Add(item);
                        gvUpcoming.DataSource = upcoming;
                        gvUpcoming.DataBind();
                        //Keep the list of upcoming bookings in a session for further use
                        Session["upcoming"] = upcoming;
                    }
                    //Displaying the past bookings
                    else
                    {
                        ItemBooking item = it;
                        history.Add(item);
                        gvHistory.DataSource = history;
                        gvHistory.DataBind();
                        //Keep the list of past bookings in a session for further use
                        Session["history"] = history;
                    }
                }
            }
            Hotel acc = (Hotel)Session["userHotel"];
            //Getting feedback from database and display them
            List <Review> feedbackList = ReviewDB.getAllHotelReviewByID(acc.HotelID);
            gvFeedback.DataSource = feedbackList;
            gvFeedback.DataBind();
            Session["Feedback"] = feedbackList;
        }
    }
 protected void gvRoom_ItemCommand(object source, DataListCommandEventArgs e)
 {
     //Allowing access to show the feedback panel to give feedback
     lbladded.Visible = false;
     if (e.CommandName == "feedback")
     {
         //Retrieving the selected item details
         List <ItemBooking> itemList = (List <ItemBooking>)Session["OldRoom"];
         ItemBooking        item     = ItemBookingDB.getAllItemBookingbyID(e.CommandArgument.ToString());
         //Showing feedback panel to allow giving feedbacks
         lblTitle.Text        = item.RoomID.Hotel.Name;
         pnlFeedback.Visible  = true;
         pnlFeedback0.Visible = false;
         pnlFeedback1.Visible = false;
         gvRoom.Visible       = true;
         Session["retrieve"]  = item;
     }
 }
 protected void gvRestaurant_ItemCommand(object source, DataListCommandEventArgs e)
 {
     //Allowing access to show the feedback panel to give feedback
     lbladded.Visible = false;
     if (e.CommandName == "feedback")
     {
         //Retrieving the selected item details to show respective feedback panel
         List <ItemBooking> itemList = (List <ItemBooking>)Session["OldRestaurant"];
         ItemBooking        item     = ItemBookingDB.getAllItemBookingbyID(e.CommandArgument.ToString());
         lblTitle1.Text = "Restaurant Name: " + item.RestaurantID.Name;
         //Showing feedback panel to allow giving feedbacks
         pnlFeedback1.Visible = true;
         pnlFeedback0.Visible = false;
         pnlFeedback.Visible  = false;
         dlRestaurant.Visible = true;
         Session["retrieve"]  = item;
         gvRoom.Visible       = false;
         dlTicket.Visible     = false;
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes the ids.
        /// </summary>
        /// <param name="itemId">The item identifier.</param>
        /// <param name="itemBriefId">The item brief identifier.</param>
        /// <param name="isItemCreated">if set to <c>true</c> [is item created].</param>
        public void InitializeIds(ref int itemId, ref int itemBriefId, ref bool isItemCreated)
        {
            InventoryBL inventoryBL = new InventoryBL(DataContext);
            ItemBriefBL itemBriefBL = new ItemBriefBL(DataContext);

            if (itemId > 0)
            {
                StageBitz.Data.Item item = inventoryBL.GetItem(itemId);

                if (item != null)
                {
                    isItemCreated = true;
                }
            }
            else if (itemBriefId > 0)
            {
                StageBitz.Data.ItemBrief itemBrief = itemBriefBL.GetItemBrief(itemBriefId);

                if (itemBrief != null)
                {
                    ItemBooking itemBooking = itemBriefBL.GetInUseItemBooking(itemBriefId);

                    Data.Item item = null;
                    if (itemBooking != null)
                    {
                        item = itemBooking.Item;
                    }

                    if (item != null)
                    {
                        itemId        = item.ItemId;
                        isItemCreated = true;
                    }
                    else
                    {
                        isItemCreated = false;
                    }
                }
            }
        }
    protected void btnGiveFeedback0_Click(object sender, EventArgs e)
    {
        //Recording the feedback when user clicked to add feedback
        pnlFeedback0.Visible = false;
        ItemBooking item   = (ItemBooking)Session["retrieve"];
        Review      review = new Review();

        //Receiving the written comment and rating to add in the database
        review.Feedback     = tbxComment0.Text;
        review.Rating       = Convert.ToInt32(tbxRatings0.Text);
        review.AttractionID = item.TicketID.Attraction;
        review.ReportStatus = ddlTicket.SelectedItem.Text;
        review.Date         = DateTime.Now;
        review.Time         = DateTime.Now;
        Customer c = (Customer)Session["user"];

        review.CustEmail = c;
        //Adding feedback with method
        int add = ReviewDB.addReviewTicket(review);

        lbladded.Visible = true;
        lbladded.Text    = "Feedback submitted successfully! Thanks for your feedback";
    }
 protected void gvUpcoming_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     lblNoResult.Visible = false;
     lblNoResult.Visible = false;
     if (e.CommandName == "Select") //if user select the upcoming bookinglist
     {
         dlRoom.Visible       = false;
         dlTicket.Visible     = false;
         dlRestaurant.Visible = false;
         List <Booking>     bookingList = (List <Booking>)Session["Upcoming"]; //retrieve the upcoming session
         Booking            book        = bookingList[gvUpcoming.PageIndex * gvUpcoming.PageSize + Convert.ToInt32(e.CommandArgument)];
         List <ItemBooking> itemList    = ItemBookingDB.getAllRoomItemBooking();
         List <ItemBooking> item        = new List <ItemBooking>();
         foreach (ItemBooking it in itemList) //use foreach to check with itembooking database
         {
             //check with the booking
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 dlRoom.Visible = true;
                 ItemBooking room = it;
                 item.Add(room);
                 //show the room details into datalist
                 dlRoom.DataSource = item;
                 dlRoom.DataBind();
                 Session["RoomItem"] = item; //create a session for room item
             }
         }
         //get the itembooking ticket details from database
         List <ItemBooking> tList = ItemBookingDB.getAllTicketItemBooking();
         //add the new list to itembooking
         List <ItemBooking> tickets = new List <ItemBooking>();
         //use foreach to check with itembooking database
         foreach (ItemBooking it in tList)
         {
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 dlTicket.Visible = true;
                 ItemBooking ticket = it;
                 tickets.Add(ticket);
                 //show the ticket details into datalist
                 dlTicket.DataSource = tickets;
                 dlTicket.DataBind();
                 Session["TicketItem"] = tickets; //create a session for ticket item
             }
         }
         //get the itembooking restaurant details from database
         List <ItemBooking> rList = ItemBookingDB.getAllRestaurantItemBooking();
         //add the new list to itembooking
         List <ItemBooking> restaurants = new List <ItemBooking>();
         //use foreach to check with itembooking database
         foreach (ItemBooking it in rList)
         {
             if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
             {
                 dlRestaurant.Visible = true;
                 ItemBooking restaurant = it;
                 restaurants.Add(restaurant);
                 //show the restaurant details into datalist
                 dlRestaurant.DataSource = restaurants;
                 dlRestaurant.DataBind();
                 Session["RestaurantItem"] = restaurants; //create a restaurant item into datalist
             }
         }
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user"] == null)
        {
            Response.Redirect("LoginForm.aspx"); //redirect to the login form, if the user is null
        }
        gvUpcoming.Visible = true;
        if (!IsPostBack)
        {
            //retrieve the user session
            Customer customer = (Customer)Session["user"];
            //get the data from booking database
            List <Booking> bookingList = BookingDB.getAllBookingByCID(customer);
            //add the new list for upcoming booking
            List <Booking> upcoming = new List <Booking>();
            foreach (Booking it in bookingList) //use foreach to get the itembooking details
            {
                List <ItemBooking> itemBookings = ItemBookingDB.getAllItemBookingbyBookingID(it.BookingID);

                ItemBooking itemBookingId = itemBookings[0]; //set an array for itembooking -- start from zero

                //use for loop to count how many itembookings
                for (int i = 0; i < itemBookings.Count - 1; i++)
                {
                    //use if statement, to check with the startdate
                    if (itemBookingId.StartDate < itemBookings[i + 1].StartDate)
                    {
                        //get the itembooking details and increase an array by one
                        itemBookingId = itemBookings[i + 1];
                    }
                }
                //check the start date from datetime.now functions
                if (itemBookingId.StartDate > DateTime.Now)
                {
                    //add the booking item into item list
                    Booking item = it;
                    upcoming.Add(item);
                    //show the upcoming item into gridview
                    gvUpcoming.DataSource = upcoming;
                    gvUpcoming.DataBind();
                }
            }
            Session["Upcoming"] = upcoming; //create upcoming session
            //create a new list for history booking
            List <Booking> history = new List <Booking>();
            //use foreach to check the bookinglist
            foreach (Booking it in bookingList)
            {
                //check the date with datetime.now functions
                if (it.Date < DateTime.Now)
                {
                    //show the history booking
                    Booking item = it;
                    history.Add(item);
                    gvHistory.DataSource = history;
                    gvHistory.DataBind();
                }
            }
            Session["History"] = history; //create a history session
        }
    }
Exemplo n.º 13
0
 protected void gvBooking_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Item") //if admin selected on the specific booking id
     {
         dlRestaurant.Visible = false;
         dlRoom.Visible       = false;
         dlTicket.Visible     = false;
         List <Booking>     bookingList = (List <Booking>)Session["Booking"];    //retrieve the booking session
         List <ItemBooking> itemList    = ItemBookingDB.getAllRoomItemBooking(); //get the data from database for room details
         List <ItemBooking> item        = new List <ItemBooking>();              //add new list into itembooking
         foreach (ItemBooking it in itemList)                                    //use foreach to check with the itembookinglist
         {
             for (int n = 0; n < bookingList.Count; n++)                         //use for loop to check how many rows are there inside of the database
             {
                 //to check whether booking is available in database
                 if (it.BookingID.BookingID.ToString() == bookingList[n].BookingID.ToString() && bookingList[n].BookingID.ToString() == e.CommandArgument.ToString())
                 {
                     //to show the room details into datalist
                     ItemBooking room = it;
                     item.Add(room);
                     dlRoom.DataSource = item;
                     dlRoom.DataBind();
                     Session["room"] = item;
                 }
             }
         }
         //retrieve the booking session
         //get the ticket item booking from database
         //add new list from itembooking classes
         List <Booking>     tList          = (List <Booking>)Session["Booking"];
         List <ItemBooking> itemTicketList = ItemBookingDB.getAllTicketItemBooking();
         List <ItemBooking> itemT          = new List <ItemBooking>();
         foreach (ItemBooking it in itemTicketList)      //use foreach to check the itembooking
         {
             for (int n = 0; n < bookingList.Count; n++) //use for loop to check how many rows are there inside of the database
             {
                 //check with the booking id, if the data is available in database
                 if (it.BookingID.BookingID.ToString() == bookingList[n].BookingID.ToString() && bookingList[n].BookingID.ToString() == e.CommandArgument.ToString())
                 {
                     //to show the ticket into datalist
                     ItemBooking ticket = it;
                     itemT.Add(ticket);
                     dlTicket.DataSource = itemT;
                     dlTicket.DataBind();
                     Session["ticket"] = it.ItemBookingID;
                 }
             }
         }
         //retrieve the booking session
         //get the restaurant item booking from database
         //add new list from itembooking classes
         List <Booking>     rList     = (List <Booking>)Session["Booking"];
         List <ItemBooking> itemRlist = ItemBookingDB.getAllRestaurantItemBooking();
         List <ItemBooking> itemR     = new List <ItemBooking>();
         foreach (ItemBooking it in itemRlist)           //use foreach to check the itembooking
         {
             for (int n = 0; n < bookingList.Count; n++) //use for loop to check how many rows are there inside of the database
             {
                 //check with the booking id, if the data is available in database
                 if (it.BookingID.BookingID.ToString() == bookingList[n].BookingID.ToString() && bookingList[n].BookingID.ToString() == e.CommandArgument.ToString())
                 {
                     //to show the restaurant details into datalist
                     ItemBooking restaurant = it;
                     itemR.Add(restaurant);
                     dlRestaurant.DataSource = itemR;
                     dlRestaurant.DataBind();
                     Session["restaurant"] = itemR;
                 }
             }
         }
         //to check the item is more than zero -- ticket, hotel room and resturant
         if (itemT.Count > 0)
         {
             dlTicket.Visible = true;
         }
         if (itemR.Count > 0)
         {
             dlRestaurant.Visible = true;
         }
         if (item.Count > 0)
         {
             dlRoom.Visible = true;
         }
     }
 }
Exemplo n.º 14
0
 public int Process([FromBody] ItemBooking Booking)
 {
     return(objBooking.ProcessBooking(Booking));
 }
Exemplo n.º 15
0
        /// <summary>
        /// Saves the item details.
        /// </summary>
        /// <param name="itemDetails">The item details.</param>
        /// <param name="skipConcurrencyCheck">if set to <c>true</c> [skip concurrency check].</param>
        /// <param name="shouldCommit">if set to <c>true</c> [should commit].</param>
        /// <returns></returns>
        public ItemResultObject SaveItemDetails(ItemDetails itemDetails, bool skipConcurrencyCheck = false, bool shouldCommit = false)
        {
            ItemResultObject itemResultObject = new ItemResultObject();
            ItemBriefBL      itemBriefBL      = new ItemBriefBL(DataContext);
            InventoryBL      inventoryBL      = new InventoryBL(DataContext);
            ProjectBL        projectBL        = new ProjectBL(DataContext);
            LocationBL       locationBL       = new LocationBL(DataContext);
            CompanyBL        companyBL        = new CompanyBL(DataContext);

            int itemId    = itemDetails.ItemId;
            int companyId = 0;
            int projectId = 0;

            Data.ItemBrief itemBrief = itemBriefBL.GetItemBrief(itemDetails.ItemBriefId);
            Data.Item      item      = inventoryBL.GetItem(itemId);

            if (itemDetails.ItemId > 0)
            {
                companyId = item.CompanyId.Value;
            }
            else if (itemBrief != null && item == null)
            {
                companyId = itemBrief.Project.CompanyId;
                projectId = itemBrief.ProjectId;

                item           = new Item();
                item.CompanyId = companyId;
            }

            bool   isInventoryPage = itemDetails.RelatedTable == "Company";
            string relatedTable    = "Company";
            int    relatedId       = companyId;

            if (itemDetails.RelatedTable == "Project" && projectId > 0)
            {
                relatedTable = itemDetails.RelatedTable;
                relatedId    = projectId;
            }

            if (!projectBL.ShouldStopProcessing(relatedTable, relatedId, itemDetails.UserId))
            {
                ErrorCodes errorCode;
                if (itemDetails.ItemBriefId > 0 && !inventoryBL.CanEditIteminItemBrief(itemDetails.ItemBriefId, itemDetails.ItemId))
                {
                    itemResultObject.Status    = "CONCURRENCY";
                    itemResultObject.ErrorCode = (int)ErrorCodes.NoEditPermissionForItemInItemBrief;
                    itemResultObject.Message   = "No Write Permission";

                    return(itemResultObject);
                }
                else if (relatedTable == "Company" && itemId > 0 && inventoryBL.CheckPermissionsForItemDetailsPage(itemDetails.UserId, itemId, companyId, out errorCode, false) == null)
                {
                    itemResultObject.Status    = "CONCURRENCY";
                    itemResultObject.ErrorCode = (int)errorCode;
                    itemResultObject.Message   = "No Write Permission";

                    return(itemResultObject);
                }
                else if (!skipConcurrencyCheck && itemId > 0 && itemDetails.LastUpdatedDate != item.LastUpdatedDate)
                {
                    itemResultObject.Status  = "NOTOK";
                    itemResultObject.Message = "Can not update";
                    return(itemResultObject);
                }

                item.Name        = itemDetails.Name;
                item.Description = itemDetails.Description;

                if (itemDetails.IsEditableToAdminOnly && item.Quantity != itemDetails.Quantity)//Commit if changes exist
                {
                    bool canSaveQty = true;
                    if (item.Quantity > itemDetails.Quantity)//Only when reduces Units
                    {
                        int maxBookedQty = inventoryBL.GetMaxBookedQuantityForAllDuration(itemDetails.ItemId);

                        if (maxBookedQty > itemDetails.Quantity)
                        {
                            canSaveQty = false;
                        }
                    }

                    if (canSaveQty)
                    {
                        item.Quantity = itemDetails.Quantity;
                    }
                    else
                    {
                        itemResultObject.Status    = "CONCURRENCY";
                        itemResultObject.ErrorCode = (int)ErrorCodes.QuantityUpdateFailed;
                        itemResultObject.Message   = "Can not reduce quantity";
                        return(itemResultObject);
                    }
                }
                item.LastUpdatedByUserId = itemDetails.UserId;
                item.LastUpdatedDate     = Utils.Now;

                if (isInventoryPage)
                {
                    if (companyBL.HasEditPermissionForInventoryStaff(companyId, itemDetails.UserId, itemDetails.LocationId))
                    {
                        item.CreatedFor = itemDetails.CreatedFor;

                        if (itemDetails.LocationId.HasValue)
                        {
                            Data.Location location = locationBL.GetLocation(itemDetails.LocationId.Value);
                            if (location == null)
                            {
                                itemResultObject.Status    = "CONCURRENCY";
                                itemResultObject.ErrorCode = (int)ErrorCodes.InventoryLocationDeleted;
                                itemResultObject.Message   = "Item Location not available";
                                return(itemResultObject);
                            }
                        }

                        item.LocationId = itemDetails.LocationId;
                    }
                    else
                    {
                        itemResultObject.Status    = "CONCURRENCY";
                        itemResultObject.ErrorCode = (int)ErrorCodes.NoEditPermissionForInventory;
                        itemResultObject.Message   = "No Edit Permission For Item In Inventory";
                        return(itemResultObject);
                    }
                }

                if (itemDetails.ItemTypeId.HasValue)
                {
                    item.ItemTypeId = itemDetails.ItemTypeId;
                }

                //Update ItemBooking
                if (itemBrief != null)
                {
                    ItemBooking itemBooking = inventoryBL.GetItemBookingByItemID(itemId, itemBrief.ItemBriefId, "ItemBrief");
                    itemBooking.Quantity       = itemDetails.Quantity.Value;
                    itemBooking.LastUpdateDate = Utils.Now;
                    itemBooking.LastUpdatedBy  = itemDetails.UserId;
                }

                if (itemDetails.ItemValues != null)
                {
                    foreach (ValuesInfo iValue in itemDetails.ItemValues)
                    {
                        if (iValue.Id == 0)
                        {
                            //It is an Insert
                            ItemValue iValueNew = new ItemValue();
                            iValueNew.ItemId        = item.ItemId;
                            iValueNew.FieldId       = iValue.FieldId;
                            iValueNew.Value         = iValue.Value;
                            iValueNew.FieldOptionId = iValue.FieldOptionId;
                            DataContext.ItemValues.AddObject(iValueNew);
                        }
                        else
                        {
                            //Update
                            ItemValue itemValue = GetItemFieldValueById(iValue.Id);
                            if (itemValue != null)
                            {
                                if (iValue.Value == string.Empty && iValue.FieldOptionId == null)
                                {
                                    DataContext.ItemValues.DeleteObject(itemValue);
                                }
                                else
                                {
                                    itemValue.FieldOptionId = iValue.FieldOptionId;
                                    itemValue.Value         = iValue.Value;
                                }
                            }
                        }
                    }
                }

                if (shouldCommit)
                {
                    DataContext.SaveChanges();
                }

                itemResultObject.Status = "OK";
                return(itemResultObject);
            }
            else
            {
                itemResultObject.Status = "STOPPROCESS";
                return(itemResultObject);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Sends the booking overdue emails.
        /// </summary>
        /// <param name="dateToConsider">The date to consider.</param>
        public static void SendBookingOverdueEmails(DateTime dateToConsider)
        {
            using (StageBitzDB dataContext = new StageBitzDB())
            {
                InventoryBL inventoryBL        = new InventoryBL(dataContext);
                int         overdueEmailCodeId = Utils.GetCodeIdByCodeValue("EmailTemplateTypeCode", "BOOKINGOVERDUE");

                var overdueBookings = (from ibs in dataContext.ItemBookings.Where(ibs => dataContext.IsItemBookingOverdueByDate(ibs.ItemBookingId, dateToConsider))
                                       from eh in dataContext.EmailHistories.Where(eh => ibs.ItemBookingId == eh.RelatedId &&
                                                                                   eh.RelatedTable == "ItemBooking" && eh.EmailTemplateTypeCodeId == overdueEmailCodeId).DefaultIfEmpty().Take(1)
                                       //join ib in dataContext.ItemBriefs on ibs.RelatedId equals ib.ItemBriefId
                                       join b in dataContext.Bookings on ibs.BookingId equals b.BookingId
                                       from ib in dataContext.ItemBriefs.Where(ib => ib.ItemBriefId == ibs.RelatedId && b.RelatedTable == "Project").DefaultIfEmpty().Take(1)
                                       join i in dataContext.Items on ibs.ItemId equals i.ItemId
                                       //                                       join b in dataContext.Bookings on ib.ProjectId equals b.RelatedId
                                       join cbn in dataContext.CompanyBookingNumbers on b.BookingId equals cbn.BookingId
                                       //join p in dataContext.Projects on ib.ProjectId equals p.ProjectId
                                       from p in dataContext.Projects.Where(p => p.ProjectId == b.RelatedId && b.RelatedTable == "Project").DefaultIfEmpty().Take(1)
                                       from np in dataContext.NonProjectBookings.Where(npb => npb.NonProjectBookingId == b.RelatedId && b.RelatedTable == "NonProject").DefaultIfEmpty().Take(1)
                                       where eh == null && ibs.IsActive && i.CompanyId.HasValue && i.CompanyId.Value == cbn.CompanyId
                                       group new { Booking = b, CompayBookingNumber = cbn, Project = p, NonProject = np, ItemBooking = ibs } by cbn.CompanyId into grp
                                       select new
                {
                    BookingInfo = grp.GroupBy(g => g.Booking.BookingId).
                                  Select(g => new
                    {
                        Booking = g.FirstOrDefault().Booking,
                        CompayBookingNumber = g.FirstOrDefault().CompayBookingNumber,
                        BookingName = g.FirstOrDefault().Project != null ? g.FirstOrDefault().Project.ProjectName : g.FirstOrDefault().NonProject.Name,
                        ItemBookingIds = g.Select(gx => gx.ItemBooking.ItemBookingId),
                        CompanyId = grp.Key
                    }),
                    CompanyId = grp.Key
                }).ToList();

                string userWebUrl = Utils.GetSystemValue("SBUserWebURL");

                Dictionary <User, List <dynamic> > userBookings = new Dictionary <User, List <dynamic> >();

                foreach (var companyBookings in overdueBookings)
                {
                    foreach (var bookingInfo in companyBookings.BookingInfo)
                    {
                        foreach (var itemBookingId in bookingInfo.ItemBookingIds)
                        {
                            ItemBooking itemBooking = inventoryBL.GetItemBooking(itemBookingId);
                            if (itemBooking != null)
                            {
                                User locationManager = inventoryBL.GetContactBookingManager(itemBooking.Item.CompanyId.Value, itemBooking.Item.LocationId);
                                if (locationManager != null)
                                {
                                    if (userBookings.Keys.Where(ul => ul.UserId == locationManager.UserId).FirstOrDefault() == null)
                                    {
                                        userBookings[locationManager] = new List <dynamic>();
                                    }

                                    User key = userBookings.Keys.Where(ul => ul.UserId == locationManager.UserId).FirstOrDefault();
                                    if (userBookings[key].Where(bi => bi.Booking.BookingId == bookingInfo.Booking.BookingId).FirstOrDefault() == null)
                                    {
                                        userBookings[key].Add(bookingInfo);
                                    }

                                    Data.EmailHistory emailHistory = new EmailHistory
                                    {
                                        EmailTemplateTypeCodeId = overdueEmailCodeId,
                                        RelatedId    = itemBookingId,
                                        RelatedTable = "ItemBooking",
                                        CreatedDate  = Utils.Now
                                    };

                                    dataContext.EmailHistories.AddObject(emailHistory);
                                }
                            }
                        }

                        dataContext.SaveChanges();
                    }
                }

                foreach (User user in userBookings.Keys)
                {
                    StringBuilder  bookingLinks = new StringBuilder();
                    List <dynamic> bookingInfos = userBookings[user];
                    foreach (dynamic bookingInfo in bookingInfos)
                    {
                        if (bookingInfo != null)
                        {
                            string url  = string.Format("{0}/Inventory/BookingDetails.aspx?BookingId={1}&CompanyId={2}", userWebUrl, bookingInfo.Booking.BookingId, bookingInfo.CompanyId);
                            string link = string.Format("Booking name: <a href='{0}' target='_blank'>{1}</a> - Booking ID: {2} <br />", url, bookingInfo.BookingName, bookingInfo.CompayBookingNumber.BookingNumber);
                            bookingLinks.Append(link);
                        }
                    }

                    EmailSender.SendBookingOverdueEmail(user.Email1, user.FirstName, bookingLinks.ToString());
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Handles the FileUploaded event of the radUploader control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="FileUploadedEventArgs"/> instance containing the event data.</param>
        protected void radUploader_FileUploaded(object sender, FileUploadedEventArgs e)
        {
            if (!PageBase.StopProcessing)
            {
                //This event will be fired for any postback from the page after the file have been asynchronosly uploaded.
                //So we should verify whether we should accept files, using a hidden field value which is set only for OK button click.

                //Only OK button will set the hidden field value to '1' from client side
                if (hdnAcceptStatus.Value == "1" && e.IsValid)
                {
                    //Reset the accept status value.
                    hdnAcceptStatus.Value = string.Empty;

                    DocumentMedia media = new DocumentMedia();

                    //File extension
                    string extension = e.File.GetExtension();
                    if (extension.Length > 0 && extension[0] == '.')
                    {
                        extension = (extension.Length > 1) ? extension.Substring(1, extension.Length - 1) : string.Empty;
                    }

                    media.IsImageFile = ImageHelper.IsImageFileType(extension);

                    switch (RelatedTableName)
                    {
                    case "ItemBrief":
                        SetMediaSortOrder(media);
                        break;

                    case "Item":
                        if (this.GetBL <InventoryBL>().IsItemDeleted(RelatedId))
                        {
                            int companyId = (int)this.GetBL <InventoryBL>().GetItem(RelatedId).CompanyId;
                            popupItemDeletedWarning.ShowItemDeleteMessagePopup(RelatedId, companyId);
                            return;
                        }

                        SetMediaSortOrder(media);
                        break;

                    case "User":
                    case "Company":
                        //User and Company can only have images via AllowedFileExtensions.
                        //But we are performing the isImageFile check just to be safe.
                        if (media.IsImageFile)
                        {
                            //Check for existing images and delete them.
                            //(Only one image can exist)
                            int[] documentMediaIds = (from m in DataContext.DocumentMedias
                                                      where m.RelatedTableName == RelatedTableName && m.RelatedId == RelatedId
                                                      select m.DocumentMediaId).ToArray();

                            foreach (int mediaId in documentMediaIds)
                            {
                                DataContext.DeleteDocumentMedia(mediaId);
                            }

                            //Set the uploaded image as the default profile image
                            media.SortOrder = 1;
                        }
                        break;

                    default:
                        break;
                    }

                    media.RelatedTableName = RelatedTableName;
                    media.RelatedId        = RelatedId;
                    media.FileExtension    = extension;
                    media.CreatedBy        = media.LastUpdatedBy = UserID;
                    media.CreatedDate      = media.LastUpdatedDate = Now;

                    if (RelatedTableName == "ItemBrief" || RelatedTableName == "Item" || RelatedTableName == "Project")
                    {
                        string label = txtName.Text.Trim();
                        if (label.Length > 0)
                        {
                            media.Name = label;
                        }
                    }

                    if (media.IsImageFile)
                    {
                        //Set image contents
                        media.DocumentMediaContent = ImageHelper.GetResizedImage(e.File.InputStream, false, extension);
                        media.Thumbnail            = ImageHelper.GetResizedImage(e.File.InputStream, true, extension);
                    }
                    else
                    {
                        using (MemoryStream memoryStream = new MemoryStream())
                        {
                            e.File.InputStream.CopyTo(memoryStream);
                            media.DocumentMediaContent = memoryStream.ToArray();
                            media.Thumbnail            = null;
                        }
                    }

                    DataContext.DocumentMedias.AddObject(media);
                    DataContext.SaveChanges();
                    DocumentMediaId = media.DocumentMediaId;

                    //Geneate notifications for projcts and item briefs. If u need notifications for different types, add them here.
                    if (RelatedTableName == "Project" || RelatedTableName == "ItemBrief")
                    {
                        this.GetBL <NotificationBL>().GenerateNotificationsForMedia(media, UserID, ProjectId, NotificationBL.OperationMode.Add);
                    }

                    //Make a Copy to the Item if available. This needs to be done at the end
                    if (RelatedTableName == "ItemBrief" && GetBL <InventoryBL>().CanEditIteminItemBrief(RelatedId))
                    {
                        ItemBooking ItemBooking = this.GetBL <InventoryBL>().GetInUseOrCompleteItemBooking(RelatedId);
                        if (ItemBooking != null && this.GetBL <InventoryBL>().CanEditIteminItemBrief(RelatedId, ItemBooking.ItemId))
                        {
                            //Since we are going to generate an Item file, we need to pass "Item" as the Releted table. Only if it is being "INUSECOMPLETE,INUSE" state.
                            DataContext.CopyMediaFiles(DocumentMediaId, "Item", ItemBooking.ItemId, UserID);
                        }
                    }

                    //Fire the file uploaded event
                    if (FileUploaded != null)
                    {
                        FileUploaded(this, EventArgs.Empty);
                    }
                }
            }
        }
    protected void dlRestaurant_ItemCommand(object source, DataListCommandEventArgs e)
    {
        //When user clicked a booking to cancel, server will send the notification email
        if (e.CommandName == "cancel")
        {
            ItemBooking item = ItemBookingDB.getAllItemBookingbyID(e.CommandArgument.ToString());
            //Sending email to both customer and service provider to inform about service cancellation
            SmtpClient client = new SmtpClient("smtp.gmail.com");
            client.EnableSsl   = true;
            client.Credentials = new NetworkCredential("*****@*****.**", "smart-travel1005");
            try
            {
                MailMessage msg = new MailMessage("*****@*****.**", item.RestaurantID.OrgEmail.ToString());
                msg.Subject = "Booking cancellation";
                msg.Body    = "Your arranged booking " + item.BookingID.BookingID + " has been cancelled";
                client.Send(msg);
            }
            //When email server is not accessible
            catch (Exception er)
            {
                lblNoResult.Visible = true;
                lblNoResult.Text    = "Internet connection required";
            }
            try
            {
                //Sending email to Customer
                MailMessage msg1 = new MailMessage("*****@*****.**", item.BookingID.CID.CustEmail.ToString());
                msg1.Subject = "Booking cancellation";
                msg1.Body    = "Your booking " + item.BookingID.BookingID + " has been cancelled";
                if (item.ItemBookingStatus != "Canceled")
                {
                    client.Send(msg1);
                }
            }
            //When email server is not accessible
            catch (Exception er)
            {
                lblNoResult.Visible = true;
                lblNoResult.Text    = "Internet connection required ";
            }

            //Booking cancellation text displayed
            lblNoResult.Visible = true;
            lblNoResult.Text    = "Your booking has been cancelled";

            //Updating booking status
            item.ItemBookingStatus = "Canceled";
            int update = ItemBookingDB.UpdateItemBooking(item);

            List <ItemBooking> itemList = ItemBookingDB.getAllRestaurantItemBooking();
            List <ItemBooking> items    = new List <ItemBooking>();
            //Reloading data to show the updated booking status
            Booking book = item.BookingID;
            foreach (ItemBooking it in itemList)
            {
                if (it.BookingID.BookingID.ToString() == book.BookingID.ToString())
                {
                    dlRoom.Visible = true;
                    ItemBooking room = it;
                    items.Add(room);
                    dlRestaurant.DataSource = items;
                    dlRestaurant.DataBind();
                    Session["RestaurantItem"] = items;
                }
            }
        }
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        //Showing result when user search by bookings by booking id
        lblCustomer.Visible = false;
        dlCustomer.Visible  = false;
        lblTitle.Text       = "Search Results";
        gvUpcoming.Visible  = false;
        gvHistory.Visible   = false;
        //Getting current signed in user
        Attraction attraction = (Attraction)Session["userAttraction"];
        //Getting booked rooms from session and display them
        List <ItemBooking> itemList  = (List <ItemBooking>)Session["Upcoming"];
        List <ItemBooking> itemList2 = (List <ItemBooking>)Session["History"];
        List <ItemBooking> upcoming  = new List <ItemBooking>();
        List <ItemBooking> history   = new List <ItemBooking>();

        //Searching in upcoming bookings
        if (itemList != null)
        {
            foreach (ItemBooking it in itemList)
            {
                if (tbxBookingID.Text == it.BookingID.BookingID.ToString())
                {
                    //showing results for upcoming bookings
                    ItemBooking item = it;
                    upcoming.Add(item);
                    gvUpcoming.DataSource = upcoming;
                    gvUpcoming.DataBind();
                    gvUpcoming.Visible  = true;
                    lblNoResult.Visible = false;
                }
                else
                {
                    lblNoResult.Text = "Sorry! No booking is found!";
                }
            }
        }
        //Searching in past booking
        if (itemList2 != null)
        {
            foreach (ItemBooking it in itemList2)
            {
                if (tbxBookingID.Text == it.BookingID.BookingID.ToString())
                {
                    //showing results for past bookings
                    ItemBooking item = it;
                    history.Add(item);
                    gvHistory.DataSource = history;
                    gvHistory.DataBind();
                    lblNoResult.Text  = "";
                    gvHistory.Visible = true;
                }
                else
                {
                    lblNoResult.Text = "Sorry! No booking is found!";
                }
            }
        }
        //if booking is not found
        if (itemList == null && itemList2 == null)
        {
            lblNoResult.Text = "Sorry! No booking is found!";
        }
        //if user click search without providing booking id, it will show upcoming bookings
        if (tbxBookingID.Text == "")
        {
            lblNoResult.Text = "";
            lblTitle.Text    = "Upcoming Booking";
            List <ItemBooking> itemList3 = (List <ItemBooking>)Session["Upcoming"];
            //Showing upcoming bookings
            gvUpcoming.DataSource = itemList3;
            gvUpcoming.DataBind();
            gvHistory.Visible  = false;
            gvUpcoming.Visible = true;
        }
    }
Exemplo n.º 20
0
        /// <summary>
        /// Gets the item details.
        /// </summary>
        /// <param name="itemId">The item identifier.</param>
        /// <param name="itemBriefId">The item brief identifier.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="itemTypeIdToBeLoad">The item type identifier to be load.</param>
        /// <param name="fromDate">From date.</param>
        /// <param name="toDate">To date.</param>
        /// <returns></returns>
        public ItemDetails GetItemDetails(int itemId, int itemBriefId, int userId, int?itemTypeIdToBeLoad, DateTime?fromDate = null, DateTime?toDate = null)
        {
            bool isItemCreated = false;
            bool isReadOnly    = false;
            int  itemTypeId    = 0;

            InventoryBL inventoryBL = new InventoryBL(DataContext);
            ItemBriefBL itemBriefBL = new ItemBriefBL(DataContext);

            ItemDetails itemDetails = new ItemDetails();

            InitializeIds(ref itemId, ref itemBriefId, ref isItemCreated);

            if (itemId > 0)
            {
                StageBitz.Data.Item item = inventoryBL.GetItem(itemId);
                if (item != null)
                {
                    ItemBooking itemBooking = null;
                    itemDetails.IsEditableToAdminOnly = true;

                    if (itemBriefId > 0)
                    {
                        ProjectBL projectBL = new ProjectBL(DataContext);
                        itemBooking = itemBriefBL.GetInUseItemBooking(itemBriefId);
                        itemDetails.CanEditInItemBrief    = inventoryBL.CanEditIteminItemBrief(itemBriefId, itemId);
                        itemDetails.IsEditableToAdminOnly = inventoryBL.IsItemGeneretedFromGivenItemBrief(itemId, itemBriefId) && !projectBL.IsReadOnlyRightsForProject(itemBriefBL.GetItemBrief(itemBriefId).ProjectId, userId, true);
                    }
                    else
                    {
                        itemDetails.MinQuantity = inventoryBL.GetMaxBookedQuantityForAllDuration(item.ItemId);

                        ItemStatusInformationForUser itemStatusInformationForUser = inventoryBL.GetItemStatusInformationForUser(item, item.CompanyId.Value, userId);
                        isReadOnly = itemStatusInformationForUser.IsReadOnly;
                        itemDetails.IsEditableToAdminOnly = itemStatusInformationForUser.CanEditQuantity;
                    }

                    itemDetails.Name        = item.Name;
                    itemDetails.Description = item.Description;
                    itemDetails.LocationId  = item.LocationId;
                    itemDetails.Quantity    = itemBooking != null ? itemBooking.Quantity : item.Quantity.HasValue ? item.Quantity.Value : item.Quantity;

                    User bookingManager = inventoryBL.GetContactBookingManager(item.CompanyId.Value, item.LocationId);
                    if (bookingManager != null)
                    {
                        itemDetails.BookingManagerName  = Utils.GetFullName(bookingManager);
                        itemDetails.BookingManagerEmail = bookingManager.Email1;
                    }

                    if (fromDate.HasValue && toDate.HasValue)
                    {
                        itemDetails.AvailableQty = DataContext.GetAvailableItemQuantity(itemId, fromDate.Value, toDate.Value, 0).FirstOrDefault().Value;
                    }
                    itemDetails.CreatedFor      = item.CreatedFor;
                    itemDetails.ItemBriefId     = itemBriefId;
                    itemDetails.LastUpdatedDate = item.LastUpdatedDate;
                    itemTypeId = itemTypeIdToBeLoad.HasValue ? itemTypeIdToBeLoad.Value : item.ItemTypeId.Value;

                    itemDetails.LastUpdatedDate = item.LastUpdatedDate;

                    itemDetails.ItemStatus = itemBooking != null?inventoryBL.GetItemBookingStatus(itemBooking.ItemBookingId).Description : string.Empty;

                    itemDetails.ItemId     = itemId;
                    itemDetails.ItemValues = GetItemFieldValues(itemId).Select(iv =>
                                                                               new ValuesInfo
                    {
                        Id            = iv.ItemValueId,
                        FieldId       = iv.FieldId,
                        FieldOptionId = iv.FieldOptionId,
                        Value         = iv.Value
                    }).ToList();

                    itemDetails.CountryId  = inventoryBL.GetCountryIdByItemId(item.ItemId);
                    itemDetails.ItemTypeId = item.ItemTypeId;
                    itemDetails.Status     = "OK";
                }
            }
            else if (itemBriefId > 0)
            {
                Data.ItemVersionHistory itemVersionHistory = inventoryBL.GetItemVersionHistoryByItemBriefId(itemBriefId);
                itemDetails.ItemBriefId = itemBriefId;
                if (itemVersionHistory != null)
                {
                    itemId                            = itemVersionHistory.ItemId;
                    itemDetails.Name                  = itemVersionHistory.Name;
                    itemDetails.Description           = itemVersionHistory.Description;
                    itemDetails.LocationId            = null; //itemVersionHistory.Location;
                    itemDetails.Quantity              = itemVersionHistory.Quantity.HasValue ? itemVersionHistory.Quantity.Value : itemDetails.Quantity;
                    itemDetails.IsEditableToAdminOnly = false;
                    itemDetails.ItemBriefId           = itemVersionHistory.ItemBriefId;
                    itemDetails.ItemValues            = GetItemVersionHistoryValues(itemVersionHistory.ItemVersionHistoryId).Select(ivhv =>
                                                                                                                                    new ValuesInfo
                    {
                        Id            = ivhv.ItemVersionHistoryId,
                        FieldId       = ivhv.FieldId,
                        FieldOptionId = ivhv.FieldOptionId,
                        Value         = ivhv.Value
                    }).ToList();
                    itemTypeId             = itemTypeIdToBeLoad.HasValue ? itemTypeIdToBeLoad.Value : itemVersionHistory.ItemTypeId.Value;
                    itemDetails.CountryId  = inventoryBL.GetCountryIdByItemId(itemVersionHistory.ItemId);
                    itemDetails.ItemTypeId = itemVersionHistory.ItemTypeId;
                    itemDetails.Status     = "OK";
                }
                else
                {
                    StageBitz.Data.ItemBrief itemBrief = itemBriefBL.GetItemBrief(itemBriefId);
                    if (itemBrief != null)
                    {
                        itemDetails.Name                  = itemBrief.Name;
                        itemDetails.Description           = itemBrief.Description;
                        itemDetails.LocationId            = null;
                        itemDetails.IsEditableToAdminOnly = true;
                        itemDetails.ItemBriefId           = itemBriefId;
                        itemDetails.Quantity              = itemBrief.Quantity.HasValue ? itemBrief.Quantity.Value : itemBrief.Quantity;
                        itemDetails.ItemBriefId           = itemBrief.ItemBriefId;
                        itemDetails.ItemValues            = GetItemBriefFieldValues(itemBriefId).Select(ibfv =>
                                                                                                        new ValuesInfo
                        {
                            Id            = 0,
                            FieldId       = ibfv.FieldId,
                            FieldOptionId = ibfv.FieldOptionId,
                            Value         = ibfv.Value
                        }).ToList();

                        itemTypeId                     = itemTypeIdToBeLoad.HasValue ? itemTypeIdToBeLoad.Value : itemBriefBL.GetItemBriefType(itemBrief.ItemBriefId).ItemTypeId;
                        itemDetails.CountryId          = itemBriefBL.GetCountryIdByItemBriefId(itemBrief.ItemBriefId);
                        itemDetails.Status             = "OK";
                        itemDetails.CanEditInItemBrief = true;
                        itemDetails.ItemTypeId         = itemBrief.ItemBriefTypes.FirstOrDefault().ItemTypeId;
                    }
                }
            }

            itemDetails.IsReadOnly    = isReadOnly;
            itemDetails.DisplayMarkUp = GetItemTypeHTML(itemTypeId);

            Data.ItemType itemType = Utils.GetItemTypeById(itemDetails.ItemTypeId.Value);
            itemDetails.ItemTypeName = itemType != null ? itemType.Name : string.Empty;

            return(itemDetails);
        }