Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpaceBookingController"/> class.
 /// MasterController
 /// </summary>
 public SpaceBookingController()
 {
     if (this.masterDataBL == null)
     {
         this.masterDataBL = new MasterDataBL();
     }
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MasterController"/> class.
 /// MasterController
 /// </summary>
 public MasterController()
 {
     if (this.masterDataBL == null)
     {
         this.masterDataBL = new MasterDataBL();
     }
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserController"/> class.
 /// UserController
 /// </summary>
 public UserController()
 {
     if (this.userDataBL == null)
     {
         this.userDataBL = new UserDataBL();
         this.commonBL   = new CommonBL();
         this.masterBL   = new MasterDataBL();
     }
 }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HomeController"/> class.
        /// MasterController
        /// </summary>
        public HomeController()
        {
            if (this.masterDataBL == null)
            {
                this.masterDataBL = new MasterDataBL();
            }

            if (this.commonBL == null)
            {
                this.commonBL = new CommonBL();
            }
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReportController"/> class.
        /// ReportController
        /// </summary>
        public ReportController()
        {
            if (this.reportdataBL == null)
            {
                this.reportdataBL = new ReportDataBL();
            }

            if (this.masterdataBL == null)
            {
                this.masterdataBL = new MasterDataBL();
            }
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MemberController"/> class.
        /// MemberController
        /// </summary>
        public MemberController()
        {
            if (this.memberDataBL == null)
            {
                this.memberDataBL = new MemberDataBL();
            }

            if (this.commonDataBL == null)
            {
                this.commonDataBL = new CommonBL();
            }

            if (this.masterDataBL == null)
            {
                this.masterDataBL = new MasterDataBL();
            }
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BookController"/> class.
        /// BookController
        /// </summary>
        public BookController()
        {
            if (this.bookDataBL == null)
            {
                this.bookDataBL = new BookDataBL();
            }

            if (this.commonBL == null)
            {
                this.commonBL = new CommonBL();
            }

            if (this.masterDataBL == null)
            {
                this.masterDataBL = new MasterDataBL();
            }
        }
Пример #8
0
        public JsonResult RescheduleBookSpace(SpaceBooking spaceBooking)
        {
            int rescheduldid = spaceBooking.ID;

            spaceBooking.ID = 0;
            try
            {
                if (this.ModelState.IsValid)
                {
                    string comment = spaceBooking.Comment;
                    spaceBooking.Comment = string.Empty;

                    spaceBooking.FromDate = DateTime.ParseExact(spaceBooking.BookingDate + " " + spaceBooking.FromTime, ProjectConfiguration.DateTimeFormat, System.Globalization.CultureInfo.InvariantCulture);
                    spaceBooking.ToDate   = DateTime.ParseExact(spaceBooking.BookingDate + " " + spaceBooking.ToTime, ProjectConfiguration.DateTimeFormat, System.Globalization.CultureInfo.InvariantCulture);

                    if (spaceBooking.FromDate <= DateTime.Now)
                    {
                        return(this.Json(new { resultData = 0, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = Messages.SpaceBookingTimeMessage }, JsonRequestBehavior.DenyGet));
                    }

                    if (spaceBooking.ToDate <= spaceBooking.FromDate)
                    {
                        return(this.Json(new { resultData = 0, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = Messages.TimeCompareMessage.SetArguments(General.ToTime, General.FromTime) }, JsonRequestBehavior.DenyGet));
                    }

                    int    status  = this.masterDataBL.AddSpaceBooking(spaceBooking, SystemEnumList.SpaceBookingStatus.Approved.GetHashCode().ToInteger());
                    string message = string.Empty;
                    if (status > 0)
                    {
                        message = Messages.SpaceBookingReschedule;

                        SpaceBooking oldspacebooking = this.masterDataBL.SelectObject <SpaceBooking>(rescheduldid);
                        string       oldSpaceName    = oldspacebooking.SpaceName;
                        oldspacebooking.StatusId     = ConvertTo.ToInteger(SystemEnumList.SpaceBookingStatus.Rescheduled.GetHashCode());
                        oldspacebooking.RescheduleId = status;
                        oldspacebooking.Reschedule   = true;
                        oldspacebooking.SpaceName    = null;
                        oldspacebooking.Comment      = comment;
                        int id = this.masterDataBL.Save <SpaceBooking>(oldspacebooking, checkForDuplicate: false);

                        if (id > 0)
                        {
                            spaceBooking.ID = status;
                            NotificationFactory.AddNotification(NotificationType.SpaceBookingReschedule, spaceBooking);

                            SpaceBooking   newSpaceBooking = this.masterDataBL.SelectObject <SpaceBooking>(status);
                            EmailViewModel emailModel      = new EmailViewModel()
                            {
                                Email       = newSpaceBooking.CustomerEmail,
                                Name        = newSpaceBooking.CustomerName,
                                OldroomName = oldSpaceName,
                                OldDate     = oldspacebooking.FromDate.ToDate().ToString(ProjectConfiguration.DateFormat, System.Globalization.CultureInfo.InvariantCulture),
                                OldFromtime = oldspacebooking.FromDate.ToDate().ToString("HH:mm", System.Globalization.CultureInfo.InvariantCulture),
                                OldTotime   = oldspacebooking.ToDate.ToDate().ToString("HH:mm", System.Globalization.CultureInfo.InvariantCulture),
                                OldPeople   = oldspacebooking.NoOfPeople.ToString(),
                                RoomName    = newSpaceBooking.SpaceName,
                                People      = spaceBooking.NoOfPeople.ToString(),
                                Date        = spaceBooking.BookingDate.ToDate().ToString(ProjectConfiguration.DateFormat, System.Globalization.CultureInfo.InvariantCulture),
                                Fromtime    = spaceBooking.FromDate.ToDate().ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture),
                                Totime      = spaceBooking.ToDate.ToDate().ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture),
                                LanguageId  = ConvertTo.ToInteger(ProjectSession.AdminPortalLanguageId)
                            };
                            UserMail.RoomBookingReschedule(emailModel);
                            return(this.Json(new { resultData = status, status = Infrastructure.SystemEnumList.MessageBoxType.Success.GetDescription(), message = message, title = General.BookSpace }, JsonRequestBehavior.DenyGet));
                        }
                        else
                        {
                            return(this.Json(new { success = false, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = Messages.ErrorMessage.SetArguments(General.BookSpace), title = Infrastructure.SystemEnumList.Title.Space.GetDescription(), JsonRequestBehavior.AllowGet }));
                        }
                    }
                    else if (status == -3)
                    {
                        var spaceCapacity = new MasterDataBL().GetSpaceList(new Space()
                        {
                            ID = spaceBooking.SpaceId.Value
                        })?.FirstOrDefault()?.Capacity ?? 0;
                        message = Messages.NoOfAttendeeExceedCapacity.SetArguments(spaceCapacity, General.NoOfPeople);
                    }
                    else if (status == -4)
                    {
                        message = Messages.BookingAreaUnavailable;
                    }
                    else
                    {
                        message = Messages.DuplicateMessage.SetArguments(General.BookSpace);
                    }

                    return(this.Json(new { resultData = status, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = message }, JsonRequestBehavior.DenyGet));
                }
                else
                {
                    string errorMsg = string.Empty;
                    foreach (ModelState modelState in this.ViewData.ModelState.Values)
                    {
                        foreach (ModelError error in modelState.Errors)
                        {
                            if (!string.IsNullOrEmpty(errorMsg))
                            {
                                errorMsg = errorMsg + " , ";
                            }

                            errorMsg = errorMsg + error.ErrorMessage;
                        }
                    }

                    return(this.Json(new { resultData = string.Empty, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = errorMsg }, JsonRequestBehavior.DenyGet));
                }
            }
            catch (Exception ex)
            {
                return(this.Json(new { resultData = string.Empty, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = ex.Message == null ? ex.InnerException.Message : ex.Message }, JsonRequestBehavior.DenyGet));
            }
        }
Пример #9
0
        public JsonResult ApproveCancelSpaceBooking(int statusId, int spaceBookingId = 0, string comment = null)
        {
            string msg = string.Empty;

            try
            {
                if (statusId == SystemEnumList.SpaceBookingStatus.Approved.GetHashCode())
                {
                    msg = SystemEnumList.SpaceBookingStatus.Approved.GetDescription();
                }
                else if (statusId == SystemEnumList.SpaceBookingStatus.Cancel.GetHashCode())
                {
                    msg = SystemEnumList.SpaceBookingStatus.Cancel.GetDescription();
                }
                else if (statusId == SystemEnumList.SpaceBookingStatus.Pending.GetHashCode())
                {
                    msg = SystemEnumList.SpaceBookingStatus.Pending.GetDescription();
                }

                SpaceBooking spacebooking = this.masterDataBL.SelectObject <SpaceBooking>(spaceBookingId);
                spacebooking.StatusId = statusId;
                string spaceName = spacebooking.SpaceName;
                spacebooking.SpaceName = null;
                if (statusId == SystemEnumList.SpaceBookingStatus.Cancel.GetHashCode())
                {
                    spacebooking.Comment = comment;
                }

                int id = this.masterDataBL.Save <SpaceBooking>(spacebooking, checkForDuplicate: false);
                if (id > 0)
                {
                    if (statusId == SystemEnumList.SpaceBookingStatus.Approved.GetHashCode())
                    {
                        EmailViewModel emailModel = new EmailViewModel()
                        {
                            Email      = spacebooking.CustomerEmail,
                            Name       = spacebooking.CustomerName,
                            People     = spacebooking.NoOfPeople.ToString(),
                            RoomName   = spaceName,
                            Date       = spacebooking.FromDate.ToDate().ToString(ProjectConfiguration.DateFormat, System.Globalization.CultureInfo.InvariantCulture),
                            Fromtime   = spacebooking.FromDate.ToDate().ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture),
                            Totime     = spacebooking.ToDate.ToDate().ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture),
                            LanguageId = ConvertTo.ToInteger(ProjectSession.AdminPortalLanguageId)
                        };
                        UserMail.RoomBookingApprove(emailModel);
                        NotificationFactory.AddNotification(NotificationType.SpaceBookingApprove, spacebooking);
                    }
                    else if (statusId == SystemEnumList.SpaceBookingStatus.Cancel.GetHashCode())
                    {
                        EmailViewModel emailModel = new EmailViewModel()
                        {
                            Email      = spacebooking.CustomerEmail,
                            Name       = spacebooking.CustomerName,
                            People     = spacebooking.NoOfPeople.ToString(),
                            RoomName   = spaceName,
                            Date       = spacebooking.FromDate.ToDate().ToString(ProjectConfiguration.DateFormat, System.Globalization.CultureInfo.InvariantCulture),
                            Fromtime   = spacebooking.FromDate.ToDate().ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture),
                            Totime     = spacebooking.ToDate.ToDate().ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture),
                            LanguageId = ConvertTo.ToInteger(ProjectSession.AdminPortalLanguageId)
                        };
                        UserMail.RoomBookingCancel(emailModel);
                        NotificationFactory.AddNotification(NotificationType.SpaceBookingReject, spacebooking);
                    }
                    else if (statusId == SystemEnumList.SpaceBookingStatus.Pending.GetHashCode())
                    {
                        NotificationFactory.AddNotification(NotificationType.SpaceBookingPending, spacebooking);
                    }

                    return(this.Json(new { success = true, status = Infrastructure.SystemEnumList.MessageBoxType.Success.GetDescription(), message = Messages.ApproveSpaceBookingStatus.SetArguments(msg), title = Infrastructure.SystemEnumList.Title.Space.GetDescription(), JsonRequestBehavior.AllowGet }));
                }
                else
                {
                    msg = Messages.ErrorMessage.SetArguments(General.BookSpace);
                    if (id == -3)
                    {
                        var spaceCapacity = new MasterDataBL().GetSpaceList(new Space()
                        {
                            ID = spaceBookingId
                        })?.FirstOrDefault()?.Capacity ?? 0;
                        msg = Messages.NoOfAttendeeExceedCapacity.SetArguments(spaceCapacity, General.NoOfPeople);
                    }
                    else if (id == -4)
                    {
                        msg = Messages.BookingAreaUnavailable;
                    }

                    return(this.Json(new { success = false, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = msg, title = Infrastructure.SystemEnumList.Title.Space.GetDescription(), JsonRequestBehavior.AllowGet }));
                }
            }
            catch (Exception ex)
            {
                return(this.Json(new { success = false, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = Messages.ErrorMessage.SetArguments(msg), title = Infrastructure.SystemEnumList.Title.Space.GetDescription(), JsonRequestBehavior.AllowGet }));
            }
        }
Пример #10
0
        public JsonResult BookSpace(SpaceBooking spaceBooking)
        {
            try
            {
                if (this.ModelState.IsValid)
                {
                    spaceBooking.FromDate = DateTime.ParseExact(spaceBooking.BookingDate + " " + spaceBooking.FromTime, ProjectConfiguration.DateTimeFormat, System.Globalization.CultureInfo.InvariantCulture);
                    spaceBooking.ToDate   = DateTime.ParseExact(spaceBooking.BookingDate + " " + spaceBooking.ToTime, ProjectConfiguration.DateTimeFormat, System.Globalization.CultureInfo.InvariantCulture);

                    if (spaceBooking.FromDate <= DateTime.Now)
                    {
                        return(this.Json(new { resultData = 0, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = Messages.SpaceBookingTimeMessage }, JsonRequestBehavior.DenyGet));
                    }

                    if (spaceBooking.ToDate <= spaceBooking.FromDate)
                    {
                        return(this.Json(new { resultData = 0, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = Messages.TimeCompareMessage.SetArguments(General.ToTime, General.FromTime) }, JsonRequestBehavior.DenyGet));
                    }

                    int    status  = this.masterDataBL.AddSpaceBooking(spaceBooking, SystemEnumList.SpaceBookingStatus.Pending.GetHashCode().ToInteger());
                    string message = string.Empty;
                    if (status > 0)
                    {
                        SmartLibrary.Services.NotificationFactory.AddNotification(SystemEnumList.NotificationType.SpaceBooking, status);
                        SpaceBooking space = this.masterDataBL.SelectObject <SpaceBooking>(status);

                        EmailViewModel emailModel = new EmailViewModel()
                        {
                            Email      = space.CustomerEmail,
                            Name       = space.CustomerName,
                            People     = space.NoOfPeople.ToString(),
                            RoomName   = space.SpaceName,
                            Date       = spaceBooking.BookingDate.ToDate().ToString(ProjectConfiguration.DateFormat, System.Globalization.CultureInfo.InvariantCulture),
                            Fromtime   = spaceBooking.FromTime.ToDate().ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture),
                            Totime     = spaceBooking.ToTime.ToDate().ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture),
                            LanguageId = ConvertTo.ToInteger(ProjectSession.UserPortalLanguageId)
                        };
                        UserMail.RoomBookingRequest(emailModel);

                        List <User> lstAdmin = this.masterDataBL.Search <User>(new User()
                        {
                            Active = true
                        }).ToList();

                        foreach (var item in lstAdmin)
                        {
                            EmailViewModel emailModelAdmin = new EmailViewModel()
                            {
                                Email      = item.Email,
                                Name       = space.CustomerName,
                                People     = spaceBooking.NoOfPeople.ToString(),
                                RoomName   = space.SpaceName,
                                Date       = spaceBooking.BookingDate.ToDate().ToString(ProjectConfiguration.DateFormat, System.Globalization.CultureInfo.InvariantCulture),
                                Fromtime   = spaceBooking.FromTime.ToDate().ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture),
                                Totime     = spaceBooking.ToTime.ToDate().ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture),
                                LanguageId = ConvertTo.ToInteger(ProjectSession.UserPortalLanguageId)
                            };
                            UserMail.RoomBookingRequestToAdmin(emailModelAdmin);
                        }

                        if (spaceBooking.ID > 0)
                        {
                            message = Messages.UpdateMessage.SetArguments(General.BookSpace);
                        }
                        else
                        {
                            message = Messages.SaveMessage.SetArguments(General.BookSpace);
                        }

                        return(this.Json(new { resultData = status, status = Infrastructure.SystemEnumList.MessageBoxType.Success.GetDescription(), message = message, title = General.BookSpace }, JsonRequestBehavior.DenyGet));
                    }
                    else if (status == -3)
                    {
                        var spaceCapacity = new MasterDataBL().GetSpaceList(new Space()
                        {
                            ID = spaceBooking.SpaceId.Value
                        })?.FirstOrDefault()?.Capacity ?? 0;
                        message = Messages.NoOfAttendeeExceedCapacity.SetArguments(spaceCapacity, General.NoOfPeople);
                    }
                    else if (status == -4)
                    {
                        message = Messages.BookingAreaUnavailable;
                    }
                    else
                    {
                        message = Messages.DuplicateMessage.SetArguments(General.BookSpace);
                    }

                    return(this.Json(new { resultData = status, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = message }, JsonRequestBehavior.DenyGet));
                }
                else
                {
                    string errorMsg = string.Empty;
                    foreach (ModelState modelState in this.ViewData.ModelState.Values)
                    {
                        foreach (ModelError error in modelState.Errors)
                        {
                            if (!string.IsNullOrEmpty(errorMsg))
                            {
                                errorMsg = errorMsg + " , ";
                            }

                            errorMsg = errorMsg + error.ErrorMessage;
                        }
                    }

                    return(this.Json(new { resultData = string.Empty, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = errorMsg }, JsonRequestBehavior.DenyGet));
                }
            }
            catch (Exception ex)
            {
                return(this.Json(new { resultData = string.Empty, status = Infrastructure.SystemEnumList.MessageBoxType.Error.GetDescription(), message = ex.Message == null ? ex.InnerException.Message : ex.Message }, JsonRequestBehavior.DenyGet));
            }
        }