protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     LandingRequest.Build(modelBuilder);
     Notice.Build(modelBuilder);
     Broadcast.Build(modelBuilder);
     IdelStar.Build(modelBuilder);
     PressCoverage.Build(modelBuilder);
     IdelTV.Build(modelBuilder);
     IdelEvent.Build(modelBuilder);
     User.Build(modelBuilder);
     Counseling.Build(modelBuilder);
     Reservation.Build(modelBuilder);
     BeforeAfter.Build(modelBuilder);
     Manager.Build(modelBuilder);
     MainSlide.Build(modelBuilder);
     base.OnModelCreating(modelBuilder);
 }
Beispiel #2
0
        public async Task <IActionResult> Detail(int?id)
        {
            var item = default(PressCoverage);

            if (id == null)
            {
                item = new PressCoverage
                {
                    Id = -1
                };
            }
            else
            {
                item = await this.Db.PressCoverages
                       .FirstOrDefaultAsync(x => x.Id == id.Value);
            }

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

            return(View(item));
        }
Beispiel #3
0
        public async Task <IActionResult> Update(int id, string link, string linktarget, string subject, string video, IFormFile thumb_pc, IFormFile img_pc, IFormFile thumb_mb, IFormFile img_mb)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(subject))
                {
                    throw new Exception("제목을 입력하세요");
                }
                if (!string.IsNullOrWhiteSpace(link) && string.IsNullOrWhiteSpace(linktarget))
                {
                    throw new Exception("링크를 입력시 링크 이동 타입을 선택해야 합니다.");
                }

                var item = default(PressCoverage);

                if (id <= 0)
                {
                    if (thumb_pc == null || thumb_mb == null)
                    {
                        throw new Exception("섬네일은 필수로 선택해야 합니다.");
                    }

                    if (img_pc == null && img_mb == null && string.IsNullOrWhiteSpace(video))
                    {
                        throw new Exception("내용 이미지 혹은 Youtube 영상정보를 입력해야 합니다.");
                    }

                    item = new PressCoverage
                    {
                        CreateTime = DateTime.Now
                    };
                    await this.Db.AddAsync(item);
                }
                else
                {
                    item = await this.Db.PressCoverages
                           .FirstOrDefaultAsync(x => x.Id == id);
                }

                item.Subject    = subject;
                item.Link       = link;
                item.LinkTarget = linktarget;
                item.VideoLink  = video;

                if (thumb_pc != null)
                {
                    var savefile = new FileInfo(Path.Combine(
                                                    Env.WebRootPath,
                                                    "images",
                                                    "upload",
                                                    "presscoverage",
                                                    DateTime.Now.ToString("yyyyMMddHHmmss_") + new FileInfo(thumb_pc.FileName).Name));

                    var url = savefile.FullName.Replace(Env.WebRootPath, $"http://{Request.Host.ToString()}").Replace("\\", "/");

                    if (!savefile.Directory.Exists)
                    {
                        savefile.Directory.Create();
                    }

                    using (var fileStream = new FileStream(savefile.FullName, FileMode.Create))
                    {
                        await thumb_pc.OpenReadStream().CopyToAsync(fileStream);
                    }

                    item.ThumbnailPC = url;
                }

                if (img_pc != null)
                {
                    var savefile = new FileInfo(Path.Combine(
                                                    Env.WebRootPath,
                                                    "images",
                                                    "upload",
                                                    "presscoverage",
                                                    DateTime.Now.ToString("yyyyMMddHHmmss_") + new FileInfo(img_pc.FileName).Name));

                    var url = savefile.FullName.Replace(Env.WebRootPath, $"http://{Request.Host.ToString()}").Replace("\\", "/");

                    if (!savefile.Directory.Exists)
                    {
                        savefile.Directory.Create();
                    }

                    using (var fileStream = new FileStream(savefile.FullName, FileMode.Create))
                    {
                        await img_pc.OpenReadStream().CopyToAsync(fileStream);
                    }

                    item.ContentPC = url;
                }

                if (thumb_mb != null)
                {
                    var savefile = new FileInfo(Path.Combine(
                                                    Env.WebRootPath,
                                                    "images",
                                                    "upload",
                                                    "presscoverage",
                                                    DateTime.Now.ToString("yyyyMMddHHmmss_") + new FileInfo(thumb_mb.FileName).Name));

                    var url = savefile.FullName.Replace(Env.WebRootPath, $"http://{Request.Host.ToString()}").Replace("\\", "/");

                    if (!savefile.Directory.Exists)
                    {
                        savefile.Directory.Create();
                    }

                    using (var fileStream = new FileStream(savefile.FullName, FileMode.Create))
                    {
                        await thumb_mb.OpenReadStream().CopyToAsync(fileStream);
                    }

                    item.ThumbnailMobile = url;
                }

                if (img_mb != null)
                {
                    var savefile = new FileInfo(Path.Combine(
                                                    Env.WebRootPath,
                                                    "images",
                                                    "upload",
                                                    "presscoverage",
                                                    DateTime.Now.ToString("yyyyMMddHHmmss_") + new FileInfo(img_mb.FileName).Name));

                    var url = savefile.FullName.Replace(Env.WebRootPath, $"http://{Request.Host.ToString()}").Replace("\\", "/");

                    if (!savefile.Directory.Exists)
                    {
                        savefile.Directory.Create();
                    }

                    using (var fileStream = new FileStream(savefile.FullName, FileMode.Create))
                    {
                        await img_mb.OpenReadStream().CopyToAsync(fileStream);
                    }

                    item.ContentMobile = url;
                }

                if (string.IsNullOrWhiteSpace(item.ContentPC) && string.IsNullOrWhiteSpace(item.ContentMobile) && string.IsNullOrWhiteSpace(item.VideoLink))
                {
                    throw new Exception("내용 이미지 혹은 Youtube 영상정보를 입력해야 합니다.");
                }

                await this.Db.SaveChangesAsync();

                return(Json(new { status = true }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, message = ex.Message }));
            }
        }