Exemple #1
0
 public bool CreateEvent([System.Web.Http.FromBody] TicketingEventsNewModel events)
 {
     Musika.Controllers.API.TicketingAPIController myController = new Musika.Controllers.API.TicketingAPIController();
     myController.UpdateTicketingEvent(events);
     return(true);
 }
Exemple #2
0
        public HttpResponseMessage GetTicketingEventsByUserID(string userID)
        {
            string result = string.Empty;
            List <Musika.Models.TicketingEventsNew> lstTicketingEvents = new List <Musika.Models.TicketingEventsNew>();

            Models.TicketingEventsNewModel model = new TicketingEventsNewModel();

            GenericRepository <TicketingEventsNew>     _ticketingEntity = new GenericRepository <TicketingEventsNew>(_unitOfWork);
            GenericRepository <TicketingUsers>         _UserEntity      = new GenericRepository <TicketingUsers>(_unitOfWork);
            GenericRepository <TicketingEventNewStaff> _StaffEvents     = new GenericRepository <TicketingEventNewStaff>(_unitOfWork);

            TicketingUsers user = new TicketingUsers();

            _unitOfWork.StartTransaction();

            try
            {
                user = _UserEntity.Repository.GetAll().Where(p => p.UserID == Convert.ToUInt32(userID)).FirstOrDefault();
                if (user != null)
                {
                    if (user.UserType == "Event Organizer")
                    {
                        lstTicketingEvents = _ticketingEntity.Repository.GetAll().Where(p => p.CreatedBy == Convert.ToInt32(userID) && p.ISDELETED != true && p.IsApproved == true).ToList();
                    }
                    else if (user.UserType == "Staff")
                    {
                        List <TicketingEventNewStaff> lstEventStaff = new List <TicketingEventNewStaff>();
                        lstEventStaff = _StaffEvents.Repository.GetAll().Where(p => p.StaffId == Convert.ToInt32(userID)).ToList();
                        if (lstEventStaff.Count > 0)
                        {
                            for (int i = 0; i < lstEventStaff.Count; i++)
                            {
                                int evtId = Convert.ToInt32(lstEventStaff[i].EventId);
                                TicketingEventsNew evt = new TicketingEventsNew();
                                evt = _ticketingEntity.Repository.GetAll().Where(p => p.EventID == evtId).FirstOrDefault();

                                lstTicketingEvents.Add(evt);
                            }
                        }
                    }
                }

                List <Models.ViewTicketingEventListNew> lstEvents = new List <Models.ViewTicketingEventListNew>();
                if (lstTicketingEvents.Count > 0)
                {
                    for (int i = 0; i < lstTicketingEvents.Count; i++)
                    {
                        Models.ViewTicketingEventListNew temp = new Models.ViewTicketingEventListNew();
                        temp.EventID   = lstTicketingEvents[i].EventID;
                        temp.StartDate = lstTicketingEvents[i].StartDate ?? DateTime.Now;
                        temp.StartTime = lstTicketingEvents[i].StartTime;
                        temp.EndDate   = lstTicketingEvents[i].EndDate ?? DateTime.Now;
                        temp.EndTime   = lstTicketingEvents[i].EndTime;
                        temp.VenueName = lstTicketingEvents[i].VenueName;
                        if (!String.IsNullOrEmpty(lstTicketingEvents[i].ArtistId.ToString()))
                        {
                            temp.ArtistName = new TicketingAPIController().GetArtistName(lstTicketingEvents[i].ArtistId);
                        }
                        else
                        {
                            temp.ArtistName = string.Empty;
                        }
                        if (!String.IsNullOrEmpty(lstTicketingEvents[i].EventImage))
                        {
                            temp.EventImage = lstTicketingEvents[i].EventImage;
                        }
                        else
                        {
                            temp.EventImage = string.Empty;
                        }
                        lstEvents.Add(temp);
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.OK, JsonResponse.GetResponse(ResponseCode.Success, lstEvents.OrderByDescending(p => p.StartDate))));
            }
            catch (Exception ee)
            {
                LogHelper.CreateLog3(ee, Request);
                _unitOfWork.RollBack();//RollBack Transaction
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ""));
            }
        }