コード例 #1
0
        public async Task <ActionResult> OrganizeEvent(EventRegistrationfromOrganizerModel model, string status)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            try
            {
                OrganiserBasicDetailsServices services = new OrganiserBasicDetailsServices();
                var            eventid = Guid.Empty;
                EventsServices obj     = new EventsServices();
                tabopen        openTab = new tabopen();
                if (model.aboutEvent != null)
                {
                    if (model.aboutEvent.NameofOrganizer != null)
                    {
                        model.aboutEvent.EventId = Guid.NewGuid();

                        model.aboutEvent.OrganizerId = User.Identity.GetUserId();
                        Session["Eventid"]           = model.aboutEvent.EventId;

                        var AboutEventTab = obj.SaveRegistrationAboutEvent(SessionToken, model).Entity;
                        openTab.Default       = false;
                        openTab.AboutEvent    = true;
                        ViewBag.AboutEventTab = AboutEventTab.Result;
                        eventid = AboutEventTab.Result;
                    }
                }
                if (model.aboutParticipants != null)
                {
                    model.aboutParticipants.OrganizerId = User.Identity.GetUserId();
                    model.aboutParticipants.EventId     = (Guid)Session["Eventid"];

                    var eventParticipant = obj.SaveORegistrtionAboutParticipant(SessionToken, model).Entity;
                    openTab.AboutParticipant    = true;
                    openTab.Default             = false;
                    ViewBag.EvantParticipanttab = eventParticipant.Result;
                    eventid = eventParticipant.Result;
                }
                if (model.importantDates != null)
                {
                    model.importantDates.OrganizerId = User.Identity.GetUserId();;
                    model.importantDates.EventId     = (Guid)Session["Eventid"];
                    var importantDates = obj.SaveImportantDateAndTime(SessionToken, model);
                    ViewBag.ImportantDates = importantDates.Entity.Result;
                    openTab.Default        = false;
                    openTab.Imortantdates  = true;
                    eventid = importantDates.Entity.Result;
                }
                if (model.awardReward != null)
                {
                    model.awardReward.OrganizerId = User.Identity.GetUserId();;


                    model.awardReward.EventId = (Guid)Session["Eventid"];
                    var AwardReward = obj.SaveAwardAndReward(SessionToken, model).Entity;
                    ViewBag.AwardandReward = AwardReward.Result;
                    openTab.Default        = false;
                    openTab.Awarcreward    = true;
                    eventid = AwardReward.Result;
                }
                if (status != null)
                {
                    using (var db = new ConquerorHubEntities())
                    {
                        CH_EventRegistrationFromOrganizer data = db.CH_EventRegistrationFromOrganizer.Where(x => x.OrganizerId == model.Imagevideo.OrganizerId && x.EventId == model.Imagevideo.EventIdImageorVideo).Select(x => x).FirstOrDefault();
                        if (status == "yes")
                        {
                            data.Eventdisplayonhomepage = true;
                        }
                        else
                        {
                            data.Eventdisplayonhomepage = false;
                        }
                    }
                }
                if (model.Imagevideo != null)
                {
                    model.Imagevideo.OrganizerId         = User.Identity.GetUserId();
                    model.Imagevideo.EventIdImageorVideo = (Guid)Session["Eventid"];
                    openTab.EventVideoImage = true;
                    //openTab.AvoidDefault = true;
                    var user1 = await services.GetEventRegistrationImageVideo(SessionToken);

                    var user = user1.Where(x => x.Imagevideo.OrganizerId == model.Imagevideo.OrganizerId && x.Imagevideo.EventIdImageorVideo == model.Imagevideo.EventIdImageorVideo).Count();

                    if (model.Imagevideo.PostedImage != null)
                    {
                        MemoryStream target1 = new MemoryStream();
                        model.Imagevideo.PostedImage.InputStream.CopyTo(target1);
                        byte[] Photo = target1.ToArray();
                        model.Imagevideo.EventImage = Photo;
                        target1.Close();
                    }
                    if (user == 1)
                    {
                        byte[] bytes1;
                        using (BinaryReader br = new BinaryReader(model.Imagevideo.PostedVideo.InputStream))
                        {
                            bytes1 = br.ReadBytes(model.Imagevideo.PostedVideo.ContentLength);
                        }
                        var data = user1.Where(x => x.Imagevideo.OrganizerId == model.Imagevideo.OrganizerId && x.Imagevideo.EventIdImageorVideo == model.Imagevideo.EventIdImageorVideo).Select(x => x).FirstOrDefault();
                        EventRegistrationfromOrganizerModel detail = new EventRegistrationfromOrganizerModel();
                        detail.Imagevideo                     = new EventsImageandVideo();
                        detail.Imagevideo.EventImage          = model.Imagevideo.EventImage;
                        detail.Imagevideo.EventVideo          = bytes1;
                        detail.Imagevideo.EventIdImageorVideo = model.Imagevideo.EventIdImageorVideo;
                        detail.Imagevideo.OrganizerId         = model.Imagevideo.OrganizerId;
                        await services.SaveEventRegistrationImageVideo(SessionToken, detail);
                    }
                }



                TempData["opentab"] = openTab;

                return(RedirectToAction("OrganizeEvent", new { eventid = Session["Eventid"] }));
            }
            catch (Exception ex)
            {
                return(View("~/Views/Errorpage/Errorpage.cshtml"));
            }
        }