Example #1
0
        public ActionResult InviteFriends(int eventPageId, int[] customerIds)
        {
            if (_workContext.CurrentCustomer.IsGuest())
            {
                return(Json(new { redirect = Url.RouteUrl("Login") }, JsonRequestBehavior.AllowGet));
            }


            var invitedCustomers = _eventPageAttendanceService.InviteFriends(eventPageId, customerIds);

            var models = new List <object>();

            foreach (var customer in invitedCustomers)
            {
                models.Add(new
                {
                    CustomerId = customer.Id,
                    FullName   = customer.GetFullName(),
                    PictureUrl = _pictureService.GetPictureUrl(
                        customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId),
                        _mobSocialSettings.EventPageAttendanceThumbnailSize, _customerSettings.DefaultAvatarEnabled,
                        defaultPictureType: PictureType.Avatar),
                    ProfileUrl = Url.RouteUrl("CustomerProfileUrl", new { SeName = SeoExtensions.GetSeName(customer, 0) }),
                });
            }

            return(Json(models));
        }
        public ActionResult UpdateAttendanceStatus(int eventPageId, int attendanceStatusId)
        {
            if (_workContext.CurrentCustomer.IsGuest())
            {
                return(Json(new { redirect = Url.RouteUrl("Login") }, JsonRequestBehavior.AllowGet));
            }



            try
            {
                if (!Enum.IsDefined(typeof(AttendanceStatus), attendanceStatusId))
                {
                    throw new ApplicationException("Invalid attendance status.");
                }


                var customerId = _workContext.CurrentCustomer.Id;
                var customerAttendanceStatus =
                    _eventPageAttendanceService.GetCustomerAttendanceStatus(eventPageId, customerId);
                var previousAttendanceStatusId = attendanceStatusId;

                if (customerAttendanceStatus == null) // new attendance
                {
                    customerAttendanceStatus = new EventPageAttendance()
                    {
                        EventPageId        = eventPageId,
                        CustomerId         = customerId,
                        AttendanceStatusId = attendanceStatusId,
                        DateCreated        = DateTime.Now,
                        DateUpdated        = DateTime.Now
                    };
                    _eventPageAttendanceService.Insert(customerAttendanceStatus);
                }
                else // update existing attendance
                {
                    previousAttendanceStatusId = customerAttendanceStatus.AttendanceStatusId;
                    customerAttendanceStatus.AttendanceStatusId = attendanceStatusId;
                    customerAttendanceStatus.DateUpdated        = DateTime.Now;
                    _eventPageAttendanceService.Update(customerAttendanceStatus);
                }

                return(Json(new {
                    PreviousAttendanceStatusId = previousAttendanceStatusId,
                    EventPageAttendanceId = customerAttendanceStatus.Id,
                    EventPageId = eventPageId,
                    CustomerId = customerId,
                    AttendanceStatusId = attendanceStatusId,
                    FullName = _workContext.CurrentCustomer.GetFullName(),
                    PictureUrl = _pictureService.GetPictureUrl(
                        _workContext.CurrentCustomer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId),
                        _mobSocialSettings.EventPageAttendanceThumbnailSize, _customerSettings.DefaultAvatarEnabled, defaultPictureType: PictureType.Avatar),
                    ProfileUrl = Url.RouteUrl("CustomerProfileUrl", new { SeName = SeoExtensions.GetSeName(_workContext.CurrentCustomer, 0) }),
                }));
            }
            catch
            {
                return(Json(false));
            }
        }
Example #3
0
        public ActionResult GetInvited(int eventPageId)
        {
            var invited = _eventPageAttendanceService.GetAllInvited(eventPageId);


            if (invited.Count == 0)
            {
                return(Json(null));
            }

            var invitedCustomers = _customerService.GetCustomersByIds(invited.Select(x => x.CustomerId).ToArray());

            var models = new List <object>();

            foreach (var customer in invitedCustomers)
            {
                models.Add(new
                {
                    CustomerId = customer.Id,
                    FullName   = customer.GetFullName(),
                    PictureUrl = _pictureService.GetPictureUrl(
                        customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId),
                        _mobSocialSettings.EventPageAttendanceThumbnailSize, _customerSettings.DefaultAvatarEnabled,
                        defaultPictureType: PictureType.Avatar),
                    ProfileUrl = Url.RouteUrl("CustomerProfileUrl", new { SeName = SeoExtensions.GetSeName(customer, 0) }),
                });
            }

            return(Json(models));
        }
Example #4
0
        public ActionResult GetAttendance(int start, int count, int attendanceStatusId)
        {
            if (Enum.IsDefined(typeof(AttendanceStatus), attendanceStatusId))
            {
                return(Json(null));
            }


            var attendances          = new List <EventPageAttendance>();
            var attendanceStatusName = string.Empty;


            switch (attendanceStatusId)
            {
            case (int)AttendanceStatus.Invited:
                attendanceStatusName = AttendanceStatus.Invited.ToString();
                attendances          = _eventPageAttendanceService.GetInvited(start, count);
                break;

            case (int)AttendanceStatus.Going:
                attendanceStatusName = AttendanceStatus.Going.ToString();
                attendances          = _eventPageAttendanceService.GetGoing(start, count);
                break;

            case (int)AttendanceStatus.Maybe:
                attendanceStatusName = AttendanceStatus.Maybe.ToString();
                attendances          = _eventPageAttendanceService.GetMaybies(start, count);
                break;

            case (int)AttendanceStatus.NotGoing:
                attendanceStatusName = AttendanceStatus.NotGoing.ToString();
                attendances          = _eventPageAttendanceService.GetNotGoing(start, count);
                break;
            }

            var customerIds = attendances.Select(x => x.CustomerId).ToArray();
            var customers   = _customerService.GetCustomersByIds(customerIds);

            var models = new List <object>();

            foreach (var customer in customers)
            {
                models.Add(new
                {
                    FullName   = customer.GetFullName(),
                    PictureUrl = _pictureService.GetPictureUrl(
                        customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId),
                        _mobSocialSettings.EventPageAttendanceThumbnailSize, _customerSettings.DefaultAvatarEnabled,
                        defaultPictureType: PictureType.Avatar),
                    ProfileUrl = Url.RouteUrl("CustomerProfileUrl", new { SeName = SeoExtensions.GetSeName(customer, 0) }),
                });
            }

            return(Json(new
            {
                AttendanceStatusName = attendanceStatusName,
                Customers = models
            }));
        }
Example #5
0
        public ActionResult Create(EventPageModel model, bool continueEditing)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            //    return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var entity = new EventPage()
                {
                    Name                  = model.Name,
                    LocationName          = model.LocationName,
                    LocationAddress1      = model.LocationAddress1,
                    LocationAddress2      = model.LocationAddress2,
                    LocationCity          = model.City,
                    LocationState         = model.LocationState,
                    LocationZipPostalCode = model.ZipPostalCode,
                    LocationPhone         = model.Phone,
                    LocationWebsite       = model.Website,
                    LocationEmail         = model.Email,
                    LocationCountry       = model.LocationCountry,
                    StartDate             = model.StartDate,
                    EndDate               = model.EndDate,
                    Description           = model.Description,
                    MetaKeywords          = model.MetaKeywords,
                    MetaDescription       = model.MetaDescription,
                    DateCreated           = DateTime.Now,
                    DateUpdated           = DateTime.Now,
                };

                //search engine name
                model.SeName = SeoExtensions.GetSeName(entity, _workContext.WorkingLanguage.Id);

                // todo: add event hosts
                _eventPageService.Insert(entity);

                //save hotels
                //SaveEventHotels(product, ParseProductTags(model.ProductTags));

                //activity log
                //_customerActivityService.InsertActivity("AddNewProduct", _localizationService.GetResource("ActivityLog.AddNewProduct"), product.Name);
                _customerActivityService.InsertActivity("AddNewEventPage", _localizationService.GetResource("ActivityLog.AddNewEventPage"), entity.Name);


                SuccessNotification(_localizationService.GetResource("Admin.MobSocial.EventPage.Added"));

                return(continueEditing ? RedirectToAction("Edit", new { id = entity.Id }) : RedirectToAction("List"));
            }

            return(View("~/Plugins/Widgets.mobSocial/Views/mobSocial/Admin/ManageEventPage/Create.cshtml", model));
        }
        private void WriteBusinessPages(UrlHelper urlHelper)
        {
            var businessPages = _businessPageService.GetAll();

            foreach (var businessPage in businessPages)
            {
                var url = urlHelper.RouteUrl("BusinessPageUrl", new { SeName = SeoExtensions.GetSeName(businessPage, _workContext.WorkingLanguage.Id) }, "http");

                if (url != null)
                {
                    var updateTime = businessPage.DateUpdated;
                    WriteUrlLocation(url, UpdateFrequency.Weekly, updateTime);
                }
            }
        }
        private void WriteProfilePages(UrlHelper urlHelper)
        {
            var customers = _customerService.GetAllCustomers();

            var registeredCustomers = customers.Where(x => !x.Deleted && x.Active);

            foreach (var customer in registeredCustomers)
            {
                var url = urlHelper.RouteUrl("CustomerProfileUrl", new { SeName = SeoExtensions.GetSeName(customer, _workContext.WorkingLanguage.Id) }, "http");

                if (url != null)
                {
                    var updateTime = customer.LastActivityDateUtc;
                    WriteUrlLocation(url, UpdateFrequency.Weekly, updateTime);
                }
            }
        }
Example #8
0
        public IHttpActionResult SearchTermAutoComplete(string term = "", bool excludeLoggedInUser = true)
        {
            if (String.IsNullOrWhiteSpace(term) || term.Length < _mobSocialSettings.PeopleSearchTermMinimumLength)
            {
                return(Json(new object()));
            }

            _mobSocialSettings.PeopleSearchAutoCompleteNumberOfResults = 10;

            //TODO: Find a better way to implement this search

            //a search term may be first name or last name...nopcommerce puts an 'and' filter rather than an 'or' filter.
            //we therefore need to first get all the customers and then filter them according to name

            var customerRole    = _customerService.GetCustomerRoleBySystemName("Registered");
            var customerRoleIds = new int[1];

            if (customerRole != null)
            {
                customerRoleIds[0] = customerRole.Id;
            }

            var customers = _customerProfileService.SearchCustomers(term, customerRoleIds, excludeLoggedInUser, true,
                                                                    _mobSocialSettings.PeopleSearchAutoCompleteNumberOfResults);

            var models = new List <object>();

            foreach (var c in customers)
            {
                models.Add(new
                {
                    DisplayName = c.GetFullName(),
                    PictureUrl  = _pictureService.GetPictureUrl(
                        c.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId), 50),
                    ProfileUrl = "/" + SeoExtensions.GetSeName(c, 0),
                    Id         = c.Id
                });
            }

            return(Json(models));
        }
Example #9
0
        public ActionResult Edit(int id)
        {
            //todo: add later
            //if (!_permissionService.Authorize(MobSocialPermissionProvider.ManageEventPages))
            //    return AccessDeniedView();

            var item = _eventPageService.GetById(id);

            if (item == null) //Not found
            {
                return(RedirectToAction("List"));
            }


            var model = new EventPageModel()
            {
                Id              = item.Id,
                Name            = item.Name,
                SeName          = SeoExtensions.GetSeName(item, _workContext.WorkingLanguage.Id),
                LocationName    = item.LocationName,
                Address1        = item.LocationAddress1,
                Address2        = item.LocationAddress2,
                City            = item.LocationCity,
                LocationState   = item.LocationState,
                ZipPostalCode   = item.LocationZipPostalCode,
                LocationCountry = item.LocationCountry,
                Phone           = item.LocationPhone,
                Website         = item.LocationWebsite,
                Email           = item.LocationEmail,
                StartDate       = item.StartDate,
                EndDate         = item.EndDate,
                Description     = item.Description,
                DateCreated     = item.DateCreated,
                DateUpdated     = item.DateUpdated,
                MetaDescription = item.MetaDescription,
                MetaKeywords    = item.MetaKeywords,
            };

            return(View("~/Plugins/Widgets.mobSocial/Views/mobSocial/Admin/ManageEventPage/Edit.cshtml", model));
        }
Example #10
0
        public ActionResult GetUninvitedFriends(int eventPageId, int index)
        {
            var customerId = _workContext.CurrentCustomer.Id;

            var uninvitedFriends = _eventPageAttendanceService.GetUninvitedFriends(eventPageId, customerId,
                                                                                   index, 20);


            if (uninvitedFriends.Count == 0)
            {
                return(Json(null));
            }

            var uninvitedFriendsAsCustomers = _customerService.GetCustomersByIds(
                uninvitedFriends.Select(x => (x.ToCustomerId == customerId)
                    ? x.FromCustomerId
                    : x.ToCustomerId)
                .ToArray());

            var models = new List <object>();

            foreach (var customer in uninvitedFriendsAsCustomers)
            {
                models.Add(new
                {
                    CustomerId = customer.Id,
                    FullName   = customer.GetFullName(),
                    PictureUrl = _pictureService.GetPictureUrl(
                        customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId),
                        _mobSocialSettings.EventPageAttendanceThumbnailSize, _customerSettings.DefaultAvatarEnabled,
                        defaultPictureType: PictureType.Avatar),
                    ProfileUrl = Url.RouteUrl("CustomerProfileUrl", new { SeName = SeoExtensions.GetSeName(customer, 0) }),
                });
            }

            return(Json(models));
        }
Example #11
0
        public ActionResult Edit(EventPageModel model, bool continueEditing)
        {
            //todo: add later
            //if (!_permissionService.Authorize(MobSocialPermissionProvider.ManageEventPages))
            //    return AccessDeniedView();

            var item = _eventPageService.GetById(model.Id);

            if (item == null)
            {
                //No product found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                item.Name                  = model.Name;
                item.LocationName          = model.LocationName;
                item.LocationAddress1      = model.Address1;
                item.LocationAddress2      = model.Address2;
                item.LocationCity          = model.City;
                item.LocationState         = model.LocationState;
                item.LocationZipPostalCode = model.ZipPostalCode;
                item.LocationCountry       = model.LocationCountry;
                item.LocationPhone         = model.Phone;
                item.LocationWebsite       = model.Website;
                item.LocationEmail         = model.Email;
                item.StartDate             = model.StartDate;
                item.EndDate               = model.EndDate;
                item.Description           = model.Description;
                item.MetaKeywords          = model.MetaKeywords;
                item.MetaDescription       = model.MetaDescription;

                item.DateUpdated = DateTime.Now;


                _eventPageService.Update(item);

                //search engine name
                model.SeName = SeoExtensions.GetSeName(item, _workContext.WorkingLanguage.Id);

                _urlRecordService.SaveSlug(item, model.SeName, _workContext.WorkingLanguage.Id);

                //picture seo names
                //UpdatePictureSeoNames(product);

                SuccessNotification(_localizationService.GetResource("Admin.MobSocial.EventPage.Updated"));

                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("Edit", new { id = item.Id }));
                }
                else
                {
                    return(RedirectToAction("List"));
                }
            }

            return(View("~/Plugins/Widgets.mobSocial/Views/mobSocial/Admin/ManageEventPage/Edit.cshtml", model));
        }
        public IHttpActionResult SearchTermAutoComplete(string term = "", bool excludeLoggedInUser = true)
        {
            if (String.IsNullOrWhiteSpace(term) || term.Length < _mobSocialSettings.PeopleSearchTermMinimumLength)
            {
                return(Json(new object()));
            }

            _mobSocialSettings.PeopleSearchAutoCompleteNumberOfResults = 10;

            //TODO: Find a better way to implement this search

            //a search term may be first name or last name...nopcommerce puts an 'and' filter rather than an 'or' filter.
            //we therefore need to first get all the customers and then filter them according to name

            var customerRole    = _customerService.GetCustomerRoleBySystemName("Registered");
            var customerRoleIds = new int[1];

            if (customerRole != null)
            {
                customerRoleIds[0] = customerRole.Id;
            }

            var customers = _customerService.GetAllCustomers(null, null, 0, 0, customerRoleIds).ToList();

            customers = excludeLoggedInUser ? customers.Where(x => x.Id != _workContext.CurrentCustomer.Id).ToList() : customers;
            var count = _mobSocialSettings.PeopleSearchAutoCompleteNumberOfResults;

            term = term.ToLowerInvariant();
            var filteredCustomers = new List <Customer>();

            customers.ForEach(x =>
            {
                if (filteredCustomers.Count >= _mobSocialSettings.PeopleSearchAutoCompleteNumberOfResults)
                {
                    return;
                }

                var firstName = x.GetAttribute <string>(SystemCustomerAttributeNames.FirstName);
                firstName     = firstName == null ? "" : firstName.ToLowerInvariant();
                var lastName  = x.GetAttribute <string>(SystemCustomerAttributeNames.LastName);
                lastName      = lastName == null ? "" : lastName.ToLowerInvariant();
                var email     = x.Email;
                if (!firstName.Contains(term) && !lastName.Contains(term) && email != term)
                {
                    return;
                }

                count--;
                filteredCustomers.Add(x);
            });


            var models = new List <object>();

            foreach (var c in filteredCustomers)
            {
                models.Add(new
                {
                    DisplayName = c.GetFullName(),
                    PictureUrl  = _pictureService.GetPictureUrl(
                        c.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId), 50),

                    ProfileUrl = Url.RouteUrl("CustomerProfileUrl", new RouteValueDictionary()
                    {
                        { "SeName", SeoExtensions.GetSeName(c, 0) }
                    }),
                    Id = c.Id
                });
            }

            return(Json(models));
        }
        private void WriteEventPages(UrlHelper urlHelper)
        {
            var eventPages = _eventPageService.GetAllUpcomingEvents();

            foreach (var eventPage in eventPages)
            {
                var url             = urlHelper.RouteUrl("EventPageUrl", new { SeName = SeoExtensions.GetSeName(eventPage, _workContext.WorkingLanguage.Id) }, "http");
                var updateFrequency = UpdateFrequency.Weekly;
                var updateTime      = eventPage.DateUpdated;
                WriteUrlLocation(url, updateFrequency, updateTime);
            }
        }