/// <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); }
public ActionResult CustomerEventUpdate(CameleoCustomerEventViewModel model) { var tmpCustomerEvent = _customerEventService.GetCustomerEventById(model.Id); if (tmpCustomerEvent == null) { //Customer event not found throw new ArgumentException(_localizationService.GetResource("Plugins.Cameleo.CameleoCustomerEvents.Delete.NotFound")); } //Update Customer event if (model.AcceptedStatus == (int)AcceptedStatus.ToBeCompleted || model.AcceptedStatus == (int)AcceptedStatus.Refused) { tmpCustomerEvent.Accepted = false; } else { tmpCustomerEvent.Accepted = true; } tmpCustomerEvent.AcceptedStatus = model.AcceptedStatus; tmpCustomerEvent.AcceptedImageUse = model.AcceptedImageUse; tmpCustomerEvent.Paid = model.Paid; _customerEventService.UpdateCustomerEvent(tmpCustomerEvent); //Update EventUser var tmpEventUser = _eventUserService.GetEventUserById(tmpCustomerEvent.EventUserId); tmpEventUser.isStaff = model.CameleoEventUser.isStaff; _eventUserService.UpdateEventUser(tmpEventUser); // Refresh view return(new NullJsonResult()); }
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)); }
/// <summary> /// Gets recent customer events registrations /// </summary> /// <returns>customer events</returns> public RecentRegistrationListViewModel GetRecentRegistrationListViewModel(int pageIndex = 0, int pageSize = int.MaxValue) { var query = from tr in _customerEventRepository.Table orderby tr.CreatedOnUtc descending select tr; var records = new PagedList <CameleoCustomerEvent>(query, pageIndex, pageSize); RecentRegistrationListViewModel recentRegistrationListViewModel = new RecentRegistrationListViewModel(); 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(); recentRegistrationListViewModel.RecentRegistrationList = events; recentRegistrationListViewModel.TotalCount = records.TotalCount; return(recentRegistrationListViewModel); }
public ActionResult EventDetails(int customerEventId) { //Get details for this customer event user CameleoCustomerEventViewModel customerEventViewModel = _customerEventService.GetCustomerEventViewModel(customerEventId); ViewBag.CustomerEventId = customerEventId; //Return view return(View("~/Plugins/Cameleo.CameleoEvents/Views/CameleoEvents/CustomerEvent/CameleoEventDetails.cshtml", customerEventViewModel)); }
public ActionResult RefuseImageUse2(CameleoCustomerEventViewModel model) { //Get customer event var tmpCustomerEvent = _customerEventService.GetCustomerEventById(model.Id); //Refuse image use tmpCustomerEvent.AcceptedImageUse = false; _customerEventService.UpdateCustomerEvent(tmpCustomerEvent); //Redirect to cart return(RedirectToRoute("ShoppingCart")); }
public ActionResult RefuseImageUse(CameleoCustomerEventViewModel model) { //Get customer event var tmpCustomerEvent = _customerEventService.GetCustomerEventById(model.Id); //Refuse image use tmpCustomerEvent.AcceptedImageUse = false; _customerEventService.UpdateCustomerEvent(tmpCustomerEvent); ViewBag.CustomerEventId = tmpCustomerEvent.Id; ViewBag.CustomerId = tmpCustomerEvent.CustomerId; //Return view CameleoCustomerEventViewModel customerEventViewModel = _customerEventService.GetCustomerEventViewModel(model.Id); return(View("~/Plugins/Cameleo.CameleoEvents/Views/CameleoEvents/CustomerEvent/CameleoEventDetails.cshtml", customerEventViewModel)); }
/// <summary> /// Gets a customer event user by id /// </summary> /// <returns>CameleoCustomerEventViewModel</returns> public CameleoCustomerEventViewModel GetCustomerEventViewModel(int customerEventId) { var tmpCustomerEvent = GetCustomerEventById(customerEventId); if (tmpCustomerEvent == null) { return(null); } else { CameleoCustomerEventViewModel customerEventViewModel = new CameleoCustomerEventViewModel(tmpCustomerEvent, _customerService.GetCustomerById(tmpCustomerEvent.CustomerId).Username, _localizationService.GetResource(AcceptedStatusStrings.LocalizedStringValues[tmpCustomerEvent.AcceptedStatus])); var tmpEventUser = _eventUserService.GetEventUserById(tmpCustomerEvent.EventUserId); var tmpEvent = _eventService.GetEventById(tmpEventUser.EventId); customerEventViewModel.CameleoEventUser = new CameleoEventUserViewModel(tmpEventUser, _eventUserService.GetEventUsersCount(_eventUserService.GetEventUserById(tmpCustomerEvent.EventUserId)), _eventUserService.GetAcceptedEventUsersCount(_eventUserService.GetEventUserById(tmpCustomerEvent.EventUserId))); customerEventViewModel.CameleoEvent = new CameleoEventViewModel(tmpEvent, _eventService.GetAllGroupsForEvent(tmpEventUser.EventId), _localizationService.GetResource(CameleoEventStatusStrings.LocalizedStringValues[tmpEvent.Status])); return(customerEventViewModel); } }
public ActionResult AddName(CameleoCustomerEventViewModel model) { //Get event user var tmpEventUser = _eventUserService.GetEventUserById(model.CameleoEventUser.Id); //Update first name last name and group tmpEventUser.FirstName = model.CameleoEventUser.FirstName; tmpEventUser.LastName = model.CameleoEventUser.LastName; tmpEventUser.Group = model.CameleoEventUser.Group; _eventUserService.UpdateEventUser(tmpEventUser); //Return view CameleoCustomerEventViewModel customerEventViewModel = _customerEventService.GetCustomerEventViewModel(model.Id); ViewBag.CustomerEventId = customerEventViewModel.Id; ViewBag.CustomerId = customerEventViewModel.CustomerId; return(View("~/Plugins/Cameleo.CameleoEvents/Views/CameleoEvents/CustomerEvent/CameleoEventDetails.cshtml", customerEventViewModel)); }
public ActionResult PaymentInfo(int customerEventId) { //Get details for this customer event user CameleoCustomerEventViewModel customerEventViewModel = _customerEventService.GetCustomerEventViewModel(customerEventId); ViewBag.CustomerEventId = customerEventViewModel.Id; //Staff var tmpEventUser = _eventUserService.GetEventUserById(customerEventViewModel.EventUserId); if (!(tmpEventUser == null)) { if (tmpEventUser.isStaff) { //Yes //Go to event details return(EventDetails(customerEventId)); } } //Return view return(View("~/Plugins/Cameleo.CameleoEvents/Views/CameleoEvents/PaymentInfo/PaymentInfo.cshtml", customerEventViewModel)); }
/// <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); }
public ActionResult AddNewEvent(CameleoCustomerEventViewModel model) { //Return to event list return(RedirectToAction("EventList")); }
public ActionResult Accept(CameleoCustomerEventViewModel model) { //Get customer event var tmpCustomerEvent = _customerEventService.GetCustomerEventById(model.Id); //Accept tmpCustomerEvent.Accepted = true; tmpCustomerEvent.AcceptedStatus = (int)AcceptedStatus.AcceptedPaid; //Staff user? var tmpEventUser = _eventUserService.GetEventUserById(tmpCustomerEvent.EventUserId); bool isStaff = false; if (!(tmpEventUser == null)) { if (tmpEventUser.isStaff) { //Yes //Don't make him pay isStaff = true; tmpCustomerEvent.Paid = true; } } //Update customer event _customerEventService.UpdateCustomerEvent(tmpCustomerEvent); //Model CameleoCustomerEventViewModel customerEventViewModel = _customerEventService.GetCustomerEventViewModel(model.Id); //Online payment and not staff? if (!isStaff && customerEventViewModel.CameleoEvent.OnlinePaymentEnabled) { //Add product to cart var product = _productService.GetProductBySku(CameleoEventProducts.PRODUCT_VIDEO_PROJECT); if (product == null) { //Product not found customerEventViewModel.Result = _localizationService.GetResource("plugins.cameleo.cameleocustomerevents.videoprojectproduct.notfound"); } else { //Add to cart decimal configuredPrice = customerEventViewModel.CameleoEvent.ParticipationFee.HasValue ? customerEventViewModel.CameleoEvent.ParticipationFee.Value : product.Price; var warnings = _shoppingCartService.AddToCart(_workContext.CurrentCustomer, product, ShoppingCartType.ShoppingCart, _storeContext.CurrentStore.Id, string.Empty, configuredPrice, 1, true); if (warnings.Count == 0) { //Get last added cart item var cart = _workContext.CurrentCustomer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart) .Where(sci => sci.StoreId == _storeContext.CurrentStore.Id) .OrderByDescending(sci => sci.CreatedOnUtc) .ToList(); if (cart.Count > 0) { var tmpCartItem = cart[0]; //Keep customer event id _genericAttributeService.SaveAttribute <int>(tmpCartItem, CameleoGenericAttributeNames.CameleoCustomerEvent + tmpCustomerEvent.Id, tmpCustomerEvent.Id, _storeContext.CurrentStore.Id); } } else { //Error adding to cart customerEventViewModel.Result = _localizationService.GetResource("plugins.cameleo.cameleocustomerevents.videoprojectproduct.adderror"); _logger.Error(_localizationService.GetResource("plugins.cameleo.cameleocustomerevents.videoprojectproduct.adderror") + " " + warnings.ToString()); } } if (string.IsNullOrEmpty(customerEventViewModel.Result)) { //No errors //Redirect return(View("~/Plugins/Cameleo.CameleoEvents/Views/CameleoEvents/CustomerEvent/ImageUse.cshtml", customerEventViewModel)); } } //Else show payment page ViewBag.CustomerEventId = tmpCustomerEvent.Id; ViewBag.CustomerId = tmpCustomerEvent.CustomerId; if (isStaff) { //Yes //Go to event details return(EventDetails(tmpCustomerEvent.Id)); } //Return view return(View("~/Plugins/Cameleo.CameleoEvents/Views/CameleoEvents/PaymentInfo/PaymentInfo.cshtml", customerEventViewModel)); }