Пример #1
0
        public bool UpdatePrice(int id, EventPriceViewModel model)
        {
            var price = _unitOfWork.EventPriceRepository.Get(model.Id.Value);

            if (price == null)
            {
                return(false);
            }

            price.Name = model.Name;

            if (model.Total < price.Sold)
            {
                return(false);
            }
            price.Total = model.Total;

            if (model.Price != price.Price)
            {
                var newPrice = new EventPrice
                {
                    Name    = model.Name,
                    Total   = price.Total - price.Sold,
                    Price   = model.Price,
                    EventId = price.EventId
                };
                _unitOfWork.EventPriceRepository.Insert(newPrice);

                price.Total     = price.Sold;
                price.IsRemoved = true;
            }

            _unitOfWork.Commit();
            return(true);
        }
Пример #2
0
        public void NewEventPrice(Event aEvent, int eventActivityID, decimal unitPrice)
        {
            EventPrice eventPrice = new EventPrice();

            eventPrice.EventID         = aEvent.ID;
            eventPrice.EventActivityID = eventActivityID;
            eventPrice.UnitPrice       = unitPrice;
            _entities.AddToEventPrices(eventPrice);
            //aEvent.EventPrices.Add(eventPrice);
        }
Пример #3
0
        public ActionResult DeleteEventPrice(int eventpriceid)
        {
            EventPrice delete = eventpricerepository.DeleteEventPrice(eventpriceid);

            if (delete != null)
            {
                TempData["message"] = string.Format("{0} has been deleted", delete.EventPriceName);
            }
            return(RedirectToAction("Event"));
        }
Пример #4
0
        public ActionResult Table(int localRetreatID)
        {
            string localRetreatName = _entities.Events.Single(a => a.ID == localRetreatID).Title;

            ViewData["localRetreatName"] = localRetreatName;
            ViewData["LocalRetreatID"]   = localRetreatID;

            var query3 = from localRetreatMealBookings in _entities.EventMealBookings
                         where localRetreatMealBookings.EventRegistration.EventID == localRetreatID
                         group localRetreatMealBookings by localRetreatMealBookings.EventScheduleID into result
                         select new
            {
                EventScheduleID = result.Key,
                Count           = result.Count()
            };

            List <EventMealBookingViewModel> viewModelList = new List <EventMealBookingViewModel>();
            EventMealBookingViewModel        viewModel;

            foreach (var q in query3)
            {
                var     localRertreatSchedule = _entities.EventSchedules.Single(a => a.ID == q.EventScheduleID);
                decimal unitPrice             = _entities.EventPrices.Single(a => a.EventID == localRetreatID && a.EventActivityID == localRertreatSchedule.EventActivityID).UnitPrice;
                string  mealName = String.Format("{0:d}", localRertreatSchedule.DateTimeFrom);
                mealName += ' ' + localRertreatSchedule.EventActivity.Name;

                viewModel = new EventMealBookingViewModel();
                viewModel.MealNameDate    = mealName;
                viewModel.Count           = q.Count;
                viewModel.UnitPrce        = unitPrice;
                viewModel.EventScheduleID = q.EventScheduleID;
                viewModelList.Add(viewModel);
            }

            viewModel = new EventMealBookingViewModel();
            EventPrice eventPrice = _entities.EventPrices.Single(a => a.EventID == localRetreatID && a.EventActivityID == 8); // Blessing Food

            viewModel.MealNameDate = eventPrice.EventActivity.Name;
            viewModel.Count        = (from r in _entities.EventRegistrations where r.EventID == localRetreatID select r).Count();
            viewModel.UnitPrce     = (decimal)eventPrice.UnitPrice;

            var localRetreatScheduleID = from r in _entities.EventSchedules
                                         where r.EventID == localRetreatID && r.EventActivity.Name.StartsWith("Bless") && r.EventID == localRetreatID
                                         select r.ID;

            viewModel.EventScheduleID = localRetreatScheduleID.FirstOrDefault();

            //viewModel.EventScheduleID =
            //    //_entities.EventSchedules.Single(a => a.EventActivityID == eventActivity.ID).ID;

            viewModelList.Add(viewModel);

            return(View(viewModelList));
        }
Пример #5
0
 public ActionResult AddEventPrice(EventPrice eventprice, int eventid)
 {
     if (ModelState.IsValid)
     {
         eventprice.EventID = eventid;
         eventpricerepository.SaveEventPrice(eventprice);
         TempData["message"] = string.Format("{0} has been saved", eventprice.EventPriceName);
         return(RedirectToAction("EventPrice"));
     }
     return(View(eventprice));
 }
Пример #6
0
        public EventPrice DeleteEventPrice(int eventpriceid)
        {
            EventPrice dbEntry = context.EventPrices.Find(eventpriceid);

            if (dbEntry != null)
            {
                dbEntry.EventPriceStatus = false;
                context.SaveChanges();
            }
            return(dbEntry);
        }
Пример #7
0
 private string GetTicketHtml(EventPrice item, string imageId)
 {
     return($"<hr/>" +
            $"<table>" +
            $"   <tr>" +
            $"       <td style=\"width: 70%\"><h2>{item.Event.Name} - {item.Name}</h2></td>" +
            $"       <td rowspan=\"3\"><img src=\"cid:{imageId}\"/></td>" +
            $"   </tr>" +
            $"   <tr><td><h4>At: {item.Event.Location.Name}</h5></td></tr>" +
            $"   <tr><td><h4>On: {item.Event.ShortDateTime}</h4></td></tr>" +
            $"</table>" +
            $"<hr/>");
 }
Пример #8
0
        public void AddPrice(int id, EventPriceViewModel model)
        {
            var price = new EventPrice
            {
                Name    = model.Name,
                Total   = model.Total,
                Price   = model.Price,
                EventId = id
            };

            _unitOfWork.EventPriceRepository.Insert(price);
            _unitOfWork.Commit();
        }
Пример #9
0
 public void SaveEventPrice(EventPrice eventprice)
 {
     if (eventprice.EventPriceID == 0)
     {
         eventprice.EventPriceStatus = true;
         eventprice.EventPriceDate   = DateTime.Now;
         context.EventPrices.Add(eventprice);
     }
     else
     {
         EventPrice dbEntry = context.EventPrices.Find(eventprice.EventPriceID);
         if (dbEntry != null)
         {
             dbEntry.EventPriceName   = eventprice.EventPriceName;
             dbEntry.EventPriceQuota  = eventprice.EventPriceQuota;
             dbEntry.EventPriceTotal  = eventprice.EventPriceTotal;
             dbEntry.EventPriceStatus = true;
         }
     }
     context.SaveChanges();
 }
Пример #10
0
 public static EventDto ToDto(this Event entity, EventPrice eventPrice = null)
 {
     return(new EventDto
     {
         Id = entity.EventId,
         OrganizationId = WellknownDtoIdentifiers.OrganizationId,
         ChampionshipId = entity.ChampionshipId,
         Name = entity.Name,
         Description = entity.Description,
         Date = entity.Date,
         Regulations = entity.Reglament,
         BasePrice = eventPrice?.BasePrice ?? 0,
         PaymentMultiplier = eventPrice?.PaymentMultiplier ?? 0,
         ResultsTemplate = entity.ResultsTemplate,
         StartOfRegistration = entity.StartOfRegistration.UtcDateTime,
         EndOfRegistration = entity.EndOfRegistration.UtcDateTime,
         IsSeed = entity.Seed,
         Published = entity.Published,
         Created = entity.Created.UtcDateTime,
         Updated = entity.Updated.UtcDateTime,
     });
 }
Пример #11
0
        public ActionResult EditEventPrice(int eventpriceid, int eventid)
        {
            EventPrice eventprice = db.EventPrices.Find(eventpriceid);

            return(View(eventprice));
        }