Esempio n. 1
0
        public ActionResult SaveEvent(string naziv, string opis, string datum, string datumOdpretprodaja, string datumOdProdaja, int organizator, decimal postotakprovizije, int mjesto, int dvorana, int status, Boolean prikaznaWebu, int id, string image, string videoLink, int? galleryId)
        {
            LK_Event ev = AdriaTicketData.LK_Events.FirstOrDefault(x => x.EVE_Id == id);
            if (ev == null)
                ev = new LK_Event();
            if(datum != "undefined")
            ev.EVE_Datum = DateTime.ParseExact(datum, "dd.MM.yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
            if (datumOdpretprodaja != "undefined")
            ev.EVE_DatumOdPretprodaja = DateTime.ParseExact(datumOdpretprodaja, "dd.MM.yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
            if (datumOdProdaja != "undefined")
            ev.EVE_DatumOdProdaja = DateTime.ParseExact(datumOdProdaja, "dd.MM.yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);
            ev.EVE_DvoranaId = dvorana;
            ev.EVE_FlagOnlineProdaja = true;
            ev.EVE_MjestoId = mjesto;
            ev.EVE_Naziv = naziv;
            ev.EVE_Opis =HttpUtility.HtmlDecode(opis);
            ev.EVE_ImageExist = true;
            ev.EVE_ImagePath = image;
            ev.EVE_ReklamaExist = false;
            ev.EVE_Stanje = 'A';
            ev.EVE_Timestamp = DateTime.Now;
            ev.EVE_OrganizatorId = organizator;
            ev.EVE_PostotakProvizije = postotakprovizije;
            ev.EVE_PrikaziNaWebu = prikaznaWebu;
            ev.EVE_StatusEventaId = status;
            string msg = "";
            if (id == 0)
            {
                msg = "insert";
                AdriaTicketData.LK_Events.InsertOnSubmit(ev);
            }
            else
            {
                msg = "update";
            }
            AdriaTicketData.SubmitChanges();
            if (id > 0 && videoLink != null)
            {
                BK_VideoGallery video = new BK_VideoGallery();
                video.eventID = id;
                video.videoLink = videoLink;
                AdriaTicketData.BK_VideoGalleries.InsertOnSubmit(video);
            }
            else if(id > 0 && videoLink == null)
            {
                BK_VideoGallery video = AdriaTicketData.BK_VideoGalleries.FirstOrDefault(x => x.eventID == id);
                    AdriaTicketData.BK_VideoGalleries.DeleteOnSubmit(video);
            }
            else if(id == 0 && videoLink != null)
            {
                LK_Event temp = AdriaTicketData.LK_Events.FirstOrDefault(x=> x.EVE_Naziv == naziv);
                BK_VideoGallery video = new BK_VideoGallery();
                video.eventID = temp.EVE_Id;
                video.videoLink = videoLink;
                AdriaTicketData.BK_VideoGalleries.InsertOnSubmit(video);

            }
            if (id > 0 && galleryId != null)
            {
                var galery = AdriaTicketData.BK_REL_Event_ImageGalleries.FirstOrDefault(x => x.EventId == id);
                if(galery != null)
                {
                    galery.EventId = id;
                    galery.ImageGalleriesId = Convert.ToInt16(galleryId);
                }else
                {
                    galery = new BK_REL_Event_ImageGallery();
                    galery.EventId = id;
                    galery.ImageGalleriesId = Convert.ToInt16(galleryId);
                    AdriaTicketData.BK_REL_Event_ImageGalleries.InsertOnSubmit(galery);
                }
            }
            else if (galleryId != null)
            {
                LK_Event temp = AdriaTicketData.LK_Events.FirstOrDefault(x => x.EVE_Naziv == naziv);
                BK_REL_Event_ImageGallery galery = new BK_REL_Event_ImageGallery();
                galery.EventId = temp.EVE_Id;
                galery.ImageGalleriesId = Convert.ToInt16(galleryId);
                AdriaTicketData.BK_REL_Event_ImageGalleries.InsertOnSubmit(galery);
            }
            AdriaTicketData.SubmitChanges();
               return Json(msg, JsonRequestBehavior.AllowGet);
        }
 partial void UpdateBK_REL_Event_ImageGallery(BK_REL_Event_ImageGallery instance);
 partial void DeleteBK_REL_Event_ImageGallery(BK_REL_Event_ImageGallery instance);
 partial void InsertBK_REL_Event_ImageGallery(BK_REL_Event_ImageGallery instance);