public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Event @event = await _context.Events.Where(e => !e.IsDeleted && e.Activeted && e.Id == id).FirstOrDefaultAsync();

            if (@event == null)
            {
                return(NotFound());
            }

            _context.IncludeCategoryEvent(true);
            List <Event> lastestEvent = _context.Events.Where(e => !e.IsDeleted && e.Activeted).OrderByDescending(e => e.Created_at).Take(3).ToList();

            _context.IncludeModeratorsEvent(true);

            List <Tag> tags = _context.GetTags();

            EventVM eventVM = new EventVM()
            {
                Event        = @event,
                LastestEvent = lastestEvent,
                Tags         = tags
            };

            return(View(eventVM));
        }
예제 #2
0
        public async Task <OperationDetails> AddNewEvent(EventVM eventVM, string EMail)
        {
            using (var Database = Context.Factory.GetService <IUnitOfWork>(Context.RootContext))
            {
                User user = await Database.UserManager.FindByEmailAsync(EMail);

                Calendar cal = user.UserCalendar;
                if (cal == null)
                {
                    user.UserCalendar = new Calendar {
                        User = user
                    };
                    var result2 = await Database.UserManager.UpdateAsync(user);

                    if (result2.Errors.Count() > 0)
                    {
                        return(new OperationDetails(false, result2.Errors.FirstOrDefault(), ""));
                    }
                }
                if (!IsEventSatisfiesSchedule(eventVM.EventInfo.StartTime, eventVM.EventInfo.EndTime, cal))
                {
                    return(new OperationDetails(false, "Event isn`t satisfies schedule", "DateTimes"));
                }
                AddFromEventVMtoCalendar(eventVM, cal);
                var result = await Database.UserManager.UpdateAsync(user);

                if (result.Errors.Count() > 0)
                {
                    return(new OperationDetails(false, result.Errors.FirstOrDefault(), ""));
                }
                await Database.SaveAsync();

                return(new OperationDetails(true, "Success", ""));
            }
        }
        //Display list of staff currently not allocated to event, based on event id provided
        //Staff can be added or removed in bulk in this view via ajax
        public async Task <IActionResult> Create(int eventId)
        {
            int numGuests        = (await _context.Guests.Include(g => g.Event).Where(g => g.EventId == eventId).ToListAsync()).Count();
            var unavailableStaff = await _context.Staffing.Include(g => g.Staff).Where(g => g.EventId == eventId).ToListAsync();

            var unStaff = await _context.Staff.Where(e => unavailableStaff.Any(a => a.StaffId.Equals(e.Id))).OrderBy(e => e.Id).ToListAsync();

            var staff = await _context.Staff.Except(unStaff).ToListAsync();

            bool firstAiderPresent = false;

            foreach (Staff s in unStaff)
            {
                if (firstAiderPresent == false && s.FirstAider == true)
                {
                    firstAiderPresent = true;
                }
            }
            List <StaffAttendanceVM> staffVM = new List <StaffAttendanceVM>();
            EventVM @event = new EventVM(await _context.Events.Where(e => e.IsActive == true).FirstOrDefaultAsync(e => e.Id == eventId));

            foreach (Staff s in staff)
            {
                staffVM.Add(new StaffAttendanceVM(s));
            }
            var            eventVM = new EventVM(await _context.Events.FindAsync(eventId));
            BookNewStaffVM creator = new BookNewStaffVM(staffVM.OrderBy(s => s.Surname).ToList(), firstAiderPresent, eventVM.Id, eventVM.Title, numGuests);

            return(View(creator));
        }
예제 #4
0
        public async Task <OperationDetails> EditEvent(EventVM eventVM, string EMail)
        {
            using (var Database = Context.Factory.GetService <IUnitOfWork>(Context.RootContext))
            {
                User user = await Database.UserManager.FindByEmailAsync(EMail);

                Calendar cal = user.UserCalendar;
                if (!IsEditEventSatisfiesSchedule(eventVM.EventInfo.StartTime, eventVM.EventInfo.EndTime, cal, eventVM.IdEvent))
                {
                    return(new OperationDetails(false, "Edit event isn`t satisfies schedule", "DateTimes"));
                }
                Event editThisEvent = cal.Events.First(c => c.Id == eventVM.IdEvent);
                if (editThisEvent == null)
                {
                    return(new OperationDetails(false, "Old event didn`t find in database for this user", ""));
                }

                try
                {
                    await EditEventInDatabase(Database, editThisEvent, eventVM);
                }
                catch (Exception ex)
                {
                    return(new OperationDetails(false, ex.Message, ""));
                }
                return(new OperationDetails(true, "Done", ""));
            }
        }
예제 #5
0
 public QuotationVM(Quotation quotation)
 {
     _quotation = quotation;
     Customer   = new CustomerVM(_quotation.Customer);
     Employee   = new EmployeeVM(_quotation.Employee);
     Event      = new EventVM(_quotation.Event);
 }
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            Event Eventdb = await _context.Events.FirstOrDefaultAsync(c => c.Id == id);

            if (Eventdb == null)
            {
                return(NotFound());
            }
            if (!Eventdb.IsDeleted)
            {
                Eventdb.IsDeleted = true;
            }
            else
            {
                Eventdb.IsDeleted = false;
            }
            EventVM eventVM = new EventVM
            {
                Event = Eventdb
            };

            _context.UpdateRange(Eventdb);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #7
0
 public IActionResult Create(EventVM vm)
 {
     if (ModelState.IsValid)
     {
         if (vm.Date < DateTimeOffset.UtcNow)
         {
             ModelState.AddModelError("Date", "Invalid Date.");
             return(View(vm));
         }
         var ev = _mapper.Map <Event>(vm);
         ev.Date = vm.Date.ToUniversalTime();
         _eventService.AddEvent(ev);
         var ticket = new Ticket()
         {
             TicketName  = ev.EventName + " Ticket",
             Description = ev.Description,
             ExpiryDate  = ev.Date.AddDays(1),
             Quantity    = vm.Quantity,
             EventId     = ev.Id
         };
         _ticketService.AddTicket(ticket);
         return(RedirectToAction("Index", "Home"));
     }
     return(View(vm));
 }
        //Method used to determine which route to take when accessing menu link via events
        //dependant on if a menu is already booked to the event
        public async Task <IActionResult> menuBrancher(int id)
        {
            var @event = await _context.Events.Where(e => e.IsActive == true).FirstOrDefaultAsync(m => m.Id == id);

            if (@event == null)
            {
                RedirectToAction("Index");
            }
            EventVM @eventVM = new EventVM(@event);

            if (eventVM.MenuId == 0)
            {
                return(RedirectToAction("BookMenu", new
                {
                    eventId = id,
                    message = ""
                }));
            }
            else
            {
                return(RedirectToAction("ViewMenu", new
                {
                    eventId = id,
                    menuId = eventVM.MenuId
                }));
            }
        }
예제 #9
0
        public EventVM Transform(DBModels.Event ev)
        {
            var model = new EventVM
            {
                Category     = ev.EventTypeId.HasValue ? (int)ev.EventTypeId : 0,
                CategoryName = ev.EventType.Type,
                Description  = ev.Description,
                Id           = ev.EventId,
                Image        = ev.Image,
                Location     = ev.Location,
                Name         = ev.Name,
                Active       = Convert.ToBoolean(ev.status),
                Performances = new List <PerformanceVM>()
            };

            var trans = new PerformanceTransformer();

            model.Performances = trans.Transform(ev.Performances);

            foreach (var perf in model.Performances)
            {
                perf.EventName = ev.Name;
            }


            return(model);
        }
예제 #10
0
        public async Task <IActionResult> EventEdit(int ID)
        {
            var response = await _eventiApi.GetEventAsync(ID);

            var entity = response.Content;
            var model  = new EventVM()
            {
                ID              = entity.ID,
                Name            = entity.Name,
                Description     = entity.Description,
                Start           = entity.Start,
                End             = entity.End,
                EventCategory   = entity.EventCategory,
                Image           = entity.Image,
                IsApproved      = entity.IsApproved,
                IsCanceled      = entity.IsCanceled,
                OrganizerID     = entity.OrganizerID,
                AdministratorID = entity.AdministratorID,
                VenueID         = entity.VenueID
            };

            model.Organizers = (await _eventiApi.GetOrganizerAsync()).Content.Data.Select(
                d => new SelectListItem(d.Name, d.ID.ToString())).ToList();
            model.Administrators = (await _eventiApi.GetAdministratorAsync()).Content.Data.Select(
                d => new SelectListItem(d.FirstName + " " + d.LastName, d.ID.ToString())).ToList();
            model.Venues = (await _eventiApi.GetVenueAsync()).Content.Data.Select(
                d => new SelectListItem(d.Name, d.ID.ToString())).ToList();

            return(View(model));
        }
예제 #11
0
        public IActionResult Create(EventVM wedding)
        {
            int?Id = HttpContext.Session.GetInt32("Id");

            if (Id == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (ModelState.IsValid)
            {
                if (wedding.Date < DateTime.Now)
                {
                    ModelState.AddModelError("Date", "Date Cannot be before today.");
                    return(View("New"));
                }
                User  user    = _context.Users.SingleOrDefault(u => u.UserId == Id);
                Event Wedding = new Event {
                    WedderOne = wedding.WedderOne,
                    WedderTwo = wedding.WedderTwo,
                    Date      = wedding.Date.Value,
                    Address   = wedding.Address,
                    Creator   = user
                };
                _context.Events.Add(Wedding);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }


            return(View("New"));
        }
예제 #12
0
 public ActionResult Edit(int?id)
 {
     if (id != null)
     {
         Event eve = db.Events.FirstOrDefault(ev => ev.id == id);
         if (eve != null)
         {
             EventVM model = new EventVM()
             {
                 Event  = eve,
                 Events = db.Events.ToList(),
                 Action = "Edit",
                 Button = "Edit",
                 Header = "Edit Event"
             };
             return(View("Index", model));
         }
         else
         {
             return(HttpNotFound());
         }
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
예제 #13
0
        //[Authorize]
        public async Task <IActionResult> Detail(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            else
            {
                Event eventDetails = await _db.Events.FirstOrDefaultAsync(e => e.Id == id);

                if (eventDetails == null)
                {
                    return(NotFound());
                }
                List <AppUser> user = await _userManager.Users.ToListAsync();

                List <Blog>     blog       = _db.Blogs.Take(3).ToList();
                List <Category> categories = _db.Categories.ToList();
                List <Speaker>  speaker    = _db.Speakers.ToList();
                EventVM         eventVM    = new EventVM()
                {
                    Blog     = blog,
                    Category = categories,
                    Event    = eventDetails,
                    Speaker  = speaker,
                    AppUser  = user
                };
                return(View(eventVM));
            }
        }
예제 #14
0
        public async Task <IActionResult> AddEvent(EventVM model)
        {
            if (ModelState.IsValid)
            {
                var    restaurant     = _RepositoryEvent.GetRestaurant(model.RestaurantId).Result;
                string uniqueFileName = null;


                if (model.File != null)
                {
                    string uploadsFolder = Path.Combine(_env.WebRootPath, "ImageEvent");
                    uniqueFileName = Guid.NewGuid().ToString() + "_" + model.File.FileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                    await model.File.CopyToAsync(new FileStream(filePath, FileMode.Create));
                }

                EventRestaurant newEvent = new EventRestaurant
                {
                    EventName  = model.Name,
                    DateStart  = model.DateStart,
                    DateEnd    = model.DateEnd,
                    PhotoUrl   = uniqueFileName,
                    Place      = model.Place,
                    Restaurant = restaurant
                };
                _RepositoryEvent.AddEventRestaurant(newEvent);

                return(RedirectToAction(nameof(Events)));
            }

            return(View());
        }
예제 #15
0
        public ActionResult Create(EventVM createdEvent)
        {
            try
            {
                EventDA        eventDA   = new EventDA();
                List <EventDA> eventList = new List <EventDA>();

                Mapper.Map(createdEvent, eventDA);

                eventList.Add(eventDA);
                bool success = DataAccessServiceController.EventService.SaveEvents(eventList);

                if (success == true)
                {
                    return(RedirectToAction("Success", "Application", new { area = "" }));
                }
                else
                {
                    return(RedirectToAction("Fail", "Application", new { area = "" }));
                }
            }
            catch (Exception e)
            {
                throw (new Exception("Error occured in EventsController.Create(result)"));
            }
        }
예제 #16
0
 public StaffingVM(Data.Staffing staffing, StaffVM staff, EventVM @event)
 {
     StaffId = staffing.StaffId;
     Staff   = staff;
     EventId = staffing.EventId;
     Event   = @event;
 }
        public IActionResult Put(int id, [FromBody] EventVM eventVM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }
            else
            {
                var targetEvent = db.Events.Find(id);

                if (targetEvent == null)
                {
                    return(NotFound("Event Not Found"));
                }

                targetEvent.Name            = eventVM.Name;
                targetEvent.Description     = eventVM.Description;
                targetEvent.TargetGroupSize = eventVM.TargetGroupSize ?? 0;

                db.Update(targetEvent);

                db.SaveChanges();

                return(Ok("Event Update"));
            }
        }
예제 #18
0
        public IActionResult Update(int?id)
        {
            ViewBag.Speakers = _context.Speakers.ToList();
            if (id == null)
            {
                return(NotFound());
            }
            Event DbEvent = _context.Events.Include(e => e.EventDetail).Include(e => e.EventSpeakers).
                            ThenInclude(es => es.Speaker).FirstOrDefault(e => e.Id == id);

            if (DbEvent == null)
            {
                return(NotFound());
            }
            List <Speaker> speakers = new List <Speaker>();

            foreach (EventSpeaker es in DbEvent.EventSpeakers)
            {
                speakers.Add(es.Speaker);
            }

            EventVM eventVM = new EventVM
            {
                Event         = DbEvent,
                EventDetail   = DbEvent.EventDetail,
                SpekarsModels = speakers
            };

            return(View(eventVM));
        }
예제 #19
0
        public async Task <IActionResult> Create([Bind("CustomerId,EventId,Attended")] GuestBooking guestBooking)
        {
            if (ModelState.IsValid)
            {
                var existingGuest = _context.Guests.Where(g => g.CustomerId == guestBooking.CustomerId && g.EventId == guestBooking.EventId).ToList();
                if ((existingGuest == null || existingGuest.Count == 0) && guestBooking.Attended == true)
                {
                    var     allGuests = _context.Guests.Where(g => g.EventId == guestBooking.EventId).ToList();
                    EventVM eventVM   = new EventVM(await _context.Events.FindAsync(guestBooking.EventId));
                    if (allGuests.Count >= eventVM.VenueCapacity)
                    {
                        return(BadRequest());
                    }
                    guestBooking.Attended = false;
                    _context.Add(guestBooking);
                    await _context.SaveChangesAsync();

                    return(Ok());
                }
                else if (existingGuest != null && existingGuest.Count != 0 && guestBooking.Attended == false)
                {
                    _context.Remove(existingGuest.FirstOrDefault());
                    await _context.SaveChangesAsync();

                    return(Ok());
                }
            }
            return(BadRequest());
        }
예제 #20
0
        public ActionResult Delete(int id, EventVM ovm)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Event o = EService.GetById(id);

            //OfferVM ovm = new OfferVM()
            //{
            //    OfferId = o.OfferId,
            //    Offer_Title = o.Offer_Title,
            //    Offer_description = o.Offer_description,
            //    Offre_Duration = o.Offre_Duration,
            //    Offre_Salary = o.Offre_Salary,
            //    Offer_Contract_Type = (ContractTypeVM)o.Offer_Contract_Type,
            //    Offer_Level_Of_Expertise = (OfferLevelVM)o.Offer_Level_Of_Expertise,
            //    Offer_DatePublished = o.Offer_DatePublished,
            //    Vues = o.Vues,
            //    CompanyId = o.CompanyId


            //};


            if (o == null)
            {
                return(HttpNotFound());
            }
            EService.Delete(o);
            EService.Commit();


            return(RedirectToAction("Index"));
        }
예제 #21
0
        // GET: Event/Details/5
        public ActionResult Details(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Event   evm = EService.GetById(id);
            EventVM e   = new EventVM()
            {
                EventId           = evm.EventId,
                Event_Address     = evm.Event_Address,
                Event_Date        = evm.Event_Date,
                Event_Description = evm.Event_Description,
                Event_Title       = evm.Event_Title,

                NumberOfParticipent = evm.NumberOfParticipent,
                CompanyId           = evm.CompanyId
            };


            if (evm == null)
            {
                return(HttpNotFound());
            }
            return(View(e));
        }
예제 #22
0
        public void AddEvent(EventVM eventItem, string userName)
        {
            var mapper    = new MapperConfiguration(c => c.CreateMap <EventVM, Events>()).CreateMapper();
            var mappedRes = mapper.Map <EventVM, Events>(eventItem);

            data.AddEvent(mappedRes, userName);
        }
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Event evt = await _db.Events.FindAsync(id);

            if (evt == null)
            {
                return(NotFound());
            }

            EventVM model = new EventVM()
            {
                Background    = _db.Backgrounds.FirstOrDefault(),
                Event         = _db.Events.Include(e => e.EventSpeakers).FirstOrDefault(e => e.Id == id),
                EventSpeakers = _db.EventSpeakers.Include(es => es.Speaker),
                Courses       = _db.Courses.Take(6),
                SideBlogs     = _db.Blogs.OrderByDescending(b => b.Id).Take(3)
            };

            return(View(model));
        }
        //Search results for events in selected date range in secondary event creation route
        public async Task <IActionResult> VenueSearchResults([Bind("StartDate,EndDate,TypeId,Type")] VenueSearchVM searchCriteria)
        {
            IEnumerable <EventTypeDto> eventTypes = await GetEventTypes();

            if (searchCriteria.TypeList == null)
            {
                searchCriteria.TypeList = new SelectList(eventTypes, "Id", "Title");
            }
            if (searchCriteria.Type == null || searchCriteria.TypeList == null)
            {
                searchCriteria.Type = eventTypes.First(e => e.Id == searchCriteria.TypeId).Title;
            }
            if (searchCriteria.TypeId == null)
            {
                searchCriteria.Message = "Please select an event type";
                return(View("SearchVenues", searchCriteria));
            }
            List <AvailabilitiesVM> availabilities = GetAvailability(searchCriteria.TypeId, searchCriteria.StartDate, searchCriteria.EndDate).Result.ToList();

            if (availabilities.Count == 0)
            {
                searchCriteria.Message = "No venues available on this date";
                return(View("SearchVenues", searchCriteria));
            }
            EventVM eventVM = new EventVM();

            eventVM.TypeId = searchCriteria.TypeId;
            EventVenueAvailabilityVM venueSelector = new EventVenueAvailabilityVM(eventVM, availabilities);

            return(View("SelectVenue", venueSelector));
        }
예제 #25
0
        public IActionResult postOrder(EventVM userOrder)
        {
            IActionResult result  = Unauthorized();
            Order         dbOrder = new Order();

            dbOrder.EventId        = userOrder.Id;
            dbOrder.OrderSubmitter = userOrder.UserId;
            foreach (EventMenuItem item in userOrder.Menu)
            {
                if (item.ItemQty > 0)
                {
                    OrderItem menuItem = new OrderItem();
                    menuItem.ItemID  = item.Id;
                    menuItem.ItemQty = item.ItemQty;
                    dbOrder.OrderItems.Add(menuItem);
                }
            }
            int newOrderId = _orderDAO.createOrder(dbOrder);

            if (newOrderId != 0)
            {
                foreach (OrderItem item in dbOrder.OrderItems)
                {
                    _orderDAO.PopulateOrder_Items(newOrderId, item.ItemID, item.ItemQty);
                }
                result = Ok();
            }

            return(result);
        }
예제 #26
0
        //GET: Details
        public ViewResult Details(int eventID)
        {
            EventDA eventDA = DataAccessServiceController.EventService.GetEventByID(eventID);
            EventVM evnt    = new EventVM();

            Mapper.Map(eventDA, evnt);
            return(View("Details", evnt));
        }
예제 #27
0
	void Awake()
	{
		testVM = new ListTestVM();
		eventVM = new EventVM();
		viewRoot.Bind(testVM);
		viewRoot.Bind(eventVM);
		SetUp();
	}
 public GuestBookingVM(GuestBooking booking, CustomerVM customer, EventVM @event)
 {
     CustomerId = booking.CustomerId;
     Customer   = customer;
     EventId    = booking.EventId;
     Event      = @event;
     Attended   = booking.Attended;
 }
예제 #29
0
        // GET: Events
        public ActionResult Index()
        {
            var eventVM = new EventVM();

            eventVM.EventsList = _eventsRepository.GetWhere(x => x.ID > 0);

            return(View(eventVM));
        }
예제 #30
0
        public ActionResult EventDetails(int id)
        {
            EventVM model = new EventVM();

            model.Event          = db.GetEventByYear(id);
            model.EventCountries = db.GetEventCountriesByYear(id);
            return(View(model));
        }
예제 #31
0
 void Awake()
 {
     testVM  = new ListTestVM();
     eventVM = new EventVM();
     viewRoot.Bind(testVM);
     viewRoot.Bind(eventVM);
     SetUp();
 }
예제 #32
0
        public static EventVM FromDataObject(Event evt) {
            EventVM retval = null;
            if (evt != null) {
                retval = new EventVM {
                    CreatedAt = evt.CreatedAt,
                    Date = evt.Date,
                    EventType = EventTypeVM.FromDataObject(evt.EventType),
                    EventTypeId = evt.EventTypeId,
                    FilmwebId = evt.FilmwebId,
                    Id = evt.Id,
                    IMDBId = evt.IMDBId,
                    LastUpdated = evt.LastUpdated,
                    LocationId = evt.LocationId,
                    Location = LocationVM.FromDataObject(evt.Location),
                    Name = evt.Name,
                };

                List<MemberEventScore> memEvtsScores = evt.MemberEventScores.ToList();
                if (memEvtsScores != null && memEvtsScores.Count > 0) {
                    retval.MemberEventScores = (from mes in memEvtsScores
                                                select MemberEventScoreVM.FromMemberEventScore(mes)).ToList();
                }
            }
            if (retval.MemberEventScores != null && retval.MemberEventScores.Count > 0) {
                int sum = retval.MemberEventScores.Sum(mes => mes.Score);
                retval.Score = (float)sum / (float)retval.MemberEventScores.Count;
            }
            return retval;
        }