コード例 #1
0
        public ActionResult FrontSection(FrontModel objFrontModel, FormCollection fc)
        {
            try
            {
                long sectionId = long.Parse(fc["sectionId"]);
                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrEmpty(objFrontModel.VideoLinkModel.VideoLinkUrl))
                    {
                        objFrontModel.VideoLinkModel.CreatedDate = DateTime.Now;
                        objFrontModel.VideoLinkModel.SectionId   = sectionId;
                        var vidLink = VideoLinkMap.Map(objFrontModel.VideoLinkModel);
                        _repoVideoLink.Add(vidLink);
                        _repoVideoLink.Save();
                    }
                    if (objFrontModel.BannerPic != null && objFrontModel.BannerPic.InputStream != null)
                    {
                        var file = new Models.File();

                        file.ContentType = objFrontModel.BannerPic.ContentType;
                        file.FileName    = objFrontModel.BannerPic.FileName;

                        var memoryStream = new MemoryStream();
                        objFrontModel.BannerPic.InputStream.CopyTo(memoryStream);

                        file.Content = memoryStream.ToArray();
                        file.Link    = objFrontModel.FileLink;

                        _repoFile.Add(file);
                        _repoFile.Save();

                        FrontEntityFileModel efModel = new FrontEntityFileModel();
                        var entityFile = FrontEntityFileMap.Map(efModel);
                        entityFile.SectionId = sectionId;
                        entityFile.EntityId  = 0;
                        entityFile.FileId    = file.Id;
                        _repoFrontEntityFile.Add(entityFile);
                        _repoFrontEntityFile.Save();
                    }
                }
                return(View("Front", objFrontModel));
            }
            catch (Exception e)
            {
                return(View("Front", objFrontModel));
            }
        }
コード例 #2
0
        public ActionResult ProjectUpload(UploadModel ProjectUploads)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrEmpty(ProjectUploads.VideoLinkModel.VideoLinkUrl))
                    {
                        ProjectUploads.VideoLinkModel.CreatedDate = DateTime.Now;
                        ProjectUploads.VideoLinkModel.SectionId   = 0;
                        var vidLink = VideoLinkMap.Map(ProjectUploads.VideoLinkModel);
                        _repoVideoLink.Add(vidLink);
                        _repoVideoLink.Save();
                    }
                    if (ProjectUploads.ProjectPic != null && ProjectUploads.ProjectPic.InputStream != null)
                    {
                        var file = new Models.File();

                        file.ContentType = ProjectUploads.ProjectPic.ContentType;
                        file.FileName    = ProjectUploads.ProjectPic.FileName;

                        var memoryStream = new MemoryStream();
                        ProjectUploads.ProjectPic.InputStream.CopyTo(memoryStream);

                        file.Content = memoryStream.ToArray();
                        file.Link    = ProjectUploads.FileLink;

                        _repoFile.Add(file);
                        _repoFile.Save();

                        //FrontEntityFileModel efModel = new FrontEntityFileModel();
                        //var entityFile = FrontEntityFileMap.Map(efModel);
                        //entityFile.SectionId = 0;
                        //entityFile.EntityId = 0;
                        //entityFile.FileId = file.Id;
                        //_repoFrontEntityFile.Add(entityFile);
                        //_repoFrontEntityFile.Save();
                    }
                }
                return(View(ProjectUploads));
            }
            catch (Exception e)
            {
                return(View(ProjectUploads));
            }
        }
コード例 #3
0
        public PartialViewResult FrontSearch()
        {
            //long sectionId = 0;
            //if (HttpContext.Items["one"] != null)
            //{
            long sectionId = long.Parse(HttpContext.Items["one"].ToString());
            //}
            FrontModel            objFront = new FrontModel();
            List <VideoLinkModel> lstVideo = new List <VideoLinkModel>();

            lstVideo = VideoLinkMap.Map(_repoVideoLink.GetList(x => x.SectionId == sectionId).OrderBy(x => x.CreatedDate).ToList());

            FrontModel fModel = new FrontModel();

            fModel.VideoListModel = lstVideo;

            List <FrontEntityFileModel> lstFrontEntityFile = new List <FrontEntityFileModel>();

            lstFrontEntityFile = FrontEntityFileMap.Map(_repoFrontEntityFile.GetList(x => x.SectionId == sectionId).OrderBy(x => x.Id).ToList());
            fModel.FrontEntityFileListModel = lstFrontEntityFile;
            return(PartialView("_FrontList", fModel));
            //return View(fModel);
        }