public ActionResult AccommodationNew(int propertyid)
 {
     Models.AccommodationModel data = AccommodationGet(0);// new Models.AccommodationModel() { AccommodationId = 0 };
     data.PropertyId = propertyid;
     data.ActiveTab  = "acc";
     return(PartialView("_Accommodation", data));
 }
        private Models.AccommodationModel AccommodationGet(long accommodationId)
        {
            Models.AccommodationModel data = new Models.AccommodationModel()
            {
                AccommodationId = 0
            };
            CLayer.Accommodation sub = BLayer.Accommodation.Get(accommodationId);
            if (sub != null)
            {
                data = new Models.AccommodationModel()
                {
                    AccommodationId     = sub.AccommodationId,
                    AccommodationTypeId = sub.AccommodationTypeId,
                    StayCategoryId      = sub.StayCategoryId,
                    AccommodationCount  = sub.AccommodationCount,
                    PropertyId          = sub.PropertyId,
                    Description         = sub.Description,

                    MaxNoOfChildren     = sub.MaxNoOfChildren,
                    MaxNoOfPeople       = sub.MaxNoOfPeople,
                    MinNoOfPeople       = sub.MinNoOfPeople,
                    BedRooms            = sub.BedRooms,
                    Area                = sub.Area,
                    Status              = sub.Status,
                    TotalAccommodations = sub.TotalAccommodations,
                    ActiveTab           = "acc"
                };

                data.AccommodationPictures = new Models.AccommodationPicturesModel()
                {
                    FileId                = 0,
                    AccommodationId       = data.AccommodationId,
                    PropertyId            = data.PropertyId,
                    FileName              = "",
                    AccommodationPhoto    = null,
                    AccommodationPictures = BLayer.AccommodationFiles.GetOnAccommodation(data.AccommodationId)
                };

                data.AccommodationFeatures = new Models.AccommodationFeaturesModel()
                {
                    AccommodationId = data.AccommodationId,
                    FeatureSet      = "",
                    Features        = BLayer.AccommodationFeature.GetAllWithSelectedForAccommodation(data.AccommodationId)
                };
            }
            return(data);
        }
        public ActionResult AccommodationSave(Models.AccommodationModel data)
        {
            try
            {
                string userid = User.Identity.GetUserId();
                long   id     = 0;
                long.TryParse(userid, out id);
                if (ModelState.IsValid)
                {
                    CLayer.Accommodation accmdtn = new CLayer.Accommodation()
                    {
                        AccommodationId     = data.AccommodationId,
                        PropertyId          = data.PropertyId,
                        AccommodationTypeId = data.AccommodationTypeId,
                        StayCategoryId      = data.StayCategoryId,
                        AccommodationCount  = data.AccommodationCount,
                        Description         = data.Description,

                        MaxNoOfPeople       = data.MaxNoOfPeople,
                        MaxNoOfChildren     = data.MaxNoOfChildren,
                        MinNoOfPeople       = data.MinNoOfPeople,
                        BedRooms            = data.BedRooms,
                        Area                = data.Area,
                        Status              = data.Status,
                        TotalAccommodations = data.TotalAccommodations,
                        UpdatedById         = id
                    };
                    long accId = BLayer.Accommodation.Save(accmdtn);
                    Models.PropertyModel property = GetDetails(data.PropertyId);
                    property.ActiveTab = "accommodation";
                    property.Accommodations.Accommodation = AccommodationGet(accId);
                    //property.Accommodations.Accommodation.ActiveTab = "acc";
                    return(View("Index", property));
                    //return RedirectToAction("Index", new { id = data.PropertyId });
                }
                return(Redirect("~/ErrorPage"));
            }
            catch (Exception ex)
            {
                Common.LogHandler.HandleError(ex);
                return(Redirect("~/ErrorPage"));
            }
        }
 public ActionResult AccommodationEdit(int id)
 {
     Models.AccommodationModel data = AccommodationGet(id);
     data.ActiveTab = "acc";
     return(PartialView("_Accommodation", data));
 }