Example #1
0
        /// <summary>
        /// Gets all customer events for a given customer
        /// </summary>
        /// <returns>customer events</returns>
        public CameleoCustomerEventListViewModel GetCustomerEventListViewModel(int customerId)
        {
            var records = GetAllCustomerEvents(customerId);
            CameleoCustomerEventListViewModel customerEventListViewModel = new CameleoCustomerEventListViewModel();
            var events = records
                         .Select(x =>
            {
                var m = new CameleoCustomerEventViewModel()
                {
                    Id                   = x.Id,
                    EventUserId          = x.EventUserId,
                    CustomerId           = x.CustomerId,
                    CustomerUserName     = _customerService.GetCustomerById(x.CustomerId).Username,
                    Paid                 = x.Paid,
                    Accepted             = x.Accepted,
                    AcceptedStatus       = x.AcceptedStatus,
                    AcceptedStatusString = _localizationService.GetResource(AcceptedStatusStrings.LocalizedStringValues[x.AcceptedStatus]),
                    AcceptedImageUse     = x.AcceptedImageUse,
                    CreatedOnUtc         = x.CreatedOnUtc,
                    CameleoEventUser     = new CameleoEventUserViewModel(_eventUserService.GetEventUserById(x.EventUserId), _eventUserService.GetEventUsersCount(_eventUserService.GetEventUserById(x.EventUserId)), _eventUserService.GetAcceptedEventUsersCount(_eventUserService.GetEventUserById(x.EventUserId))),
                    CameleoEvent         = new CameleoEventViewModel(_eventService.GetEventByEventUserId(x.EventUserId), _eventService.GetAllGroupsForEvent(_eventService.GetEventByEventUserId(x.EventUserId).Id), _localizationService.GetResource(CameleoEventStatusStrings.LocalizedStringValues[_eventService.GetEventByEventUserId(x.EventUserId).Status])),
                };
                return(m);
            })
                         .ToList();

            customerEventListViewModel.CameleoCustomerEventList = events;
            return(customerEventListViewModel);
        }
Example #2
0
        public ActionResult CustomerEventList(int eventId, string groupName)
        {
            //Get all customer events for this group and event
            CameleoCustomerEventListViewModel customerEventListViewModel = _customerEventService.GetCustomerEventListViewModel(eventId, groupName);
            CameleoEventViewModel             eventViewModel             = _eventService.GetEventViewModel(eventId);

            //Get remaining event users that did not answer
            var noAnswerEventUsers = _eventUserService.GetNoAnswerEventUsers(eventId, groupName);

            foreach (var tmpEventUser in noAnswerEventUsers.Reverse())
            {
                CameleoCustomerEventViewModel tmpCustomerEvent = new CameleoCustomerEventViewModel();

                tmpCustomerEvent.Id                   = -1;
                tmpCustomerEvent.EventUserId          = tmpEventUser.Id;
                tmpCustomerEvent.CustomerId           = -1;
                tmpCustomerEvent.CustomerUserName     = "";
                tmpCustomerEvent.Paid                 = false;
                tmpCustomerEvent.Accepted             = false;
                tmpCustomerEvent.AcceptedStatus       = (int)AcceptedStatus.ToBeCompleted;
                tmpCustomerEvent.AcceptedStatusString = _localizationService.GetResource(AcceptedStatusStrings.LocalizedStringValues[tmpCustomerEvent.AcceptedStatus]);
                tmpCustomerEvent.AcceptedImageUse     = false;
                tmpCustomerEvent.CameleoEvent         = eventViewModel;
                tmpCustomerEvent.CameleoEventUser     = new CameleoEventUserViewModel(tmpEventUser, 0, 0);
                customerEventListViewModel.CameleoCustomerEventList.Insert(0, tmpCustomerEvent);
            }

            //Return view
            return(PartialView("~/Plugins/Cameleo.CameleoEvents/Views/CameleoEvents/GroupDetails/CustomerEventList.cshtml", customerEventListViewModel));
        }
Example #3
0
        public ActionResult EventList()
        {
            //Get all events for this customer user
            CameleoCustomerEventListViewModel customerEventListViewModel = _customerEventService.GetCustomerEventListViewModel(_workContext.CurrentCustomer.Id);

            //Return view
            return(View("~/Plugins/Cameleo.CameleoEvents/Views/CameleoEvents/CustomerEvent/CameleoEvents.cshtml", customerEventListViewModel));
        }
Example #4
0
        public ActionResult CustomerEventListJson(int eventId, string groupName, DataSourceRequest command)
        {
            CameleoCustomerEventListViewModel customerEventListViewModel = _customerEventService.GetCustomerEventListViewModel(eventId, groupName);

            var model = new DataSourceResult
            {
                Data  = customerEventListViewModel.CameleoCustomerEventList,
                Total = customerEventListViewModel.CameleoCustomerEventList.Count
            };

            return(Json(model));
        }
Example #5
0
        /// <summary>
        /// Gets customer events related to a given group in a given event
        /// </summary>
        /// <returns>customer events</returns>
        public CameleoCustomerEventListViewModel GetCustomerEventListViewModel(int pEventId, string pGroup)
        {
            var records = GetAllCustomerEventsForGroup(pEventId, pGroup);
            CameleoCustomerEventListViewModel customerEventListViewModel = new CameleoCustomerEventListViewModel();
            var tmpEvent                  = _eventService.GetEventById(pEventId);
            var tmpEventGroups            = _eventService.GetAllGroupsForEvent(pEventId);
            var tmpEventUserCount         = _eventUserService.GetEventUsersCount(pEventId, pGroup);
            var tmpAcceptedEventUserCount = _eventUserService.GetAcceptedEventUsersCount(pEventId, pGroup);
            var events = records
                         .Select(x =>
            {
                var m = new CameleoCustomerEventViewModel()
                {
                    Id                   = x.Id,
                    EventUserId          = x.EventUserId,
                    CustomerId           = x.CustomerId,
                    CustomerUserName     = _customerService.GetCustomerById(x.CustomerId) == null ? "" : _customerService.GetCustomerById(x.CustomerId).Username,
                    Paid                 = x.Paid,
                    Accepted             = x.Accepted,
                    AcceptedStatus       = x.AcceptedStatus,
                    AcceptedStatusString = _localizationService.GetResource(AcceptedStatusStrings.LocalizedStringValues[x.AcceptedStatus]),
                    AcceptedImageUse     = x.AcceptedImageUse,
                    CreatedOnUtc         = x.CreatedOnUtc,
                    CameleoEventUser     = new CameleoEventUserViewModel(_eventUserService.GetEventUserById(x.EventUserId), tmpEventUserCount, tmpAcceptedEventUserCount),
                    CameleoEvent         = new CameleoEventViewModel(tmpEvent, tmpEventGroups, _localizationService.GetResource(CameleoEventStatusStrings.LocalizedStringValues[tmpEvent.Status])),
                };
                return(m);
            })
                         .ToList();

            customerEventListViewModel.CameleoCustomerEventList = events;
            customerEventListViewModel.ForSameGroup             = true;
            customerEventListViewModel.EventId   = pEventId;
            customerEventListViewModel.GroupName = pGroup;
            return(customerEventListViewModel);
        }
Example #6
0
        public ActionResult EventList(CameleoCustomerEventListViewModel model)
        {
            String Result = "";

            if (ModelState.IsValid)
            {
                //Find event user
                var tmpEventUser = _eventUserService.GetEventUserByUserName(model.NewCustomerEvent);
                if (tmpEventUser == null)
                {
                    //Not found
                    Result = _localizationService.GetResource("Plugins.Cameleo.CameleoEventUsers.NotFound");
                }
                else
                {
                    //Else found

                    //Check password
                    if (tmpEventUser.Password == model.Password)
                    {
                        //Password ok

                        //Check if already added
                        var tmpCustomerEvent = _customerEventService.GetCustomerEvent(tmpEventUser.Id, _workContext.CurrentCustomer.Id);
                        if (tmpCustomerEvent != null)
                        {
                            //Customer event already present
                            Result = _localizationService.GetResource("Plugins.Cameleo.CameleoCustomerEvents.Exists");
                        }
                        else
                        {
                            // Else try to add it
                            try
                            {
                                _customerEventService.InsertCustomerEvent(tmpEventUser.Id, _workContext.CurrentCustomer.Id);

                                //Go to details
                                var tmpUser = _customerEventService.GetCustomerEvent(tmpEventUser.Id, _workContext.CurrentCustomer.Id);
                                if (tmpUser != null)
                                {
                                    Result = _localizationService.GetResource("Plugins.Cameleo.CameleoCustomerEvents.InsertSuccess");
                                    return(RedirectToRoute("CameleoEventDetails", new { customerEventId = tmpUser.Id }));
                                }
                                else
                                {
                                    Result = _localizationService.GetResource("Plugins.Cameleo.CameleoCustomerEvents.InsertError");
                                }
                            }
                            catch (Exception)
                            {
                                Result = _localizationService.GetResource("Plugins.Cameleo.CameleoCustomerEvents.InsertError");
                            }
                        }
                    }
                    else
                    {
                        //Else wrong password
                        Result = _localizationService.GetResource("Plugins.Cameleo.CameleoEventUsers.WrongPassword");;
                    }
                }
            }

            //Get all events for this customer user
            CameleoCustomerEventListViewModel customerEventListViewModel = _customerEventService.GetCustomerEventListViewModel(_workContext.CurrentCustomer.Id);

            customerEventListViewModel.Result = Result;

            //Redisplay form
            return(View("~/Plugins/Cameleo.CameleoEvents/Views/CameleoEvents/CustomerEvent/CameleoEvents.cshtml", customerEventListViewModel));
        }