示例#1
0
        public IActionResult Create([FromForm] CreateFilmModel createFilmModel)
        {
            var films   = _mongoDB.GetCollection <BsonDocument>("films");
            var posters = _mongoDB.GetCollection <BsonDocument>("posters");

            var toAdd = new Film()
            {
                Director  = createFilmModel.Director,
                Storyline = createFilmModel.Storyline,
                Title     = createFilmModel.Title,
                Year      = createFilmModel.Year,
                Negative  = 0,
                Positive  = 0
            };

            byte[] posterBytes = new byte[createFilmModel.PosterFile.Length];
            createFilmModel.PosterFile.OpenReadStream().Read(posterBytes, 0, (int)createFilmModel.PosterFile.Length);

            var posterId    = ObjectId.GenerateNewId();
            var posterToAdd = new PosterModel()
            {
                Image = posterBytes,
                Id    = posterId,
            };

            posters.InsertOneAsync(posterToAdd.ToBsonDocument());

            toAdd.PosterId = posterId;

            films.InsertOneAsync(toAdd.ToBsonDocument());

            return(Redirect("/"));
        }
示例#2
0
        public IActionResult Edit([FromForm] EditFilmModel editFilmModel)
        {
            var films   = _mongoDB.GetCollection <BsonDocument>("films");
            var posters = _mongoDB.GetCollection <BsonDocument>("posters");

            GetFilm(editFilmModel.FilmId);

            Film.Director  = editFilmModel.Director;
            Film.Storyline = editFilmModel.Storyline;
            Film.Title     = editFilmModel.Title;
            Film.Year      = editFilmModel.Year;

            if (editFilmModel.PosterFile != null)
            {
                byte[] posterBytes = new byte[editFilmModel.PosterFile.Length];
                editFilmModel.PosterFile.OpenReadStream().Read(posterBytes, 0, (int)editFilmModel.PosterFile.Length);

                var posterId    = ObjectId.GenerateNewId();
                var posterToAdd = new PosterModel()
                {
                    Image = posterBytes,
                    Id    = posterId,
                };

                posters.InsertOneAsync(posterToAdd.ToBsonDocument());
                posters.DeleteOne($"{{_id: ObjectId('{Film.PosterId}')}}");
                Film.PosterId = posterId;
            }
            films.ReplaceOne($"{{_id: ObjectId('{Film.Id}')}}", Film.ToBsonDocument());

            return(Redirect("/film/detail?id=" + Film.Id.ToString()));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            PosterModel postermodel = db.Posters.Find(id);

            db.Posters.Remove(postermodel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //
        // GET: /Poster/Details/5

        public ActionResult Details(int id = 0)
        {
            PosterModel postermodel = db.Posters.Find(id);

            if (postermodel == null)
            {
                return(HttpNotFound());
            }
            return(View(postermodel));
        }
示例#5
0
        public IActionResult Index()
        {
            PosterModel model;

            model          = new PosterModel();
            model.ImageSrc = "/images/large_Event_Poster_Pasta.png";


            return(View(model));
        }
        //
        // GET: /Poster/Edit/5

        public ActionResult Edit(int id = 0)
        {
            PosterModel postermodel = db.Posters.Find(id);

            ViewBag.isNewRecord = false;
            if (postermodel == null)
            {
                return(HttpNotFound());
            }
            return(View(postermodel));
        }
 public ActionResult Edit(PosterModel postermodel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(postermodel).State = EntityState.Modified;
         postermodel.ModifyTime      = DateTime.Now;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(postermodel));
 }
示例#8
0
        public static PosterModel convertEntityToModel(tbl_posterlayout entity)
        {
            PosterModel model = new PosterModel();

            model.posterCttPositionX    = entity.posterCttPositionX;
            model.posterCttPositionY    = entity.posterCttPositionY;
            model.posterId              = entity.posterId;
            model.posterIdx             = entity.posterIdx;
            model.posterImgPositionX    = entity.posterImgPositionX;
            model.posterImgPositionY    = entity.posterImgPositionY;
            model.posterPath            = entity.posterPath;
            model.posterQRCodePositionX = entity.posterQRCodePositionX;
            model.posterQRCodePositionY = entity.posterQRCodePositionY;

            return(model);
        }
        public ActionResult Create(PosterModel postermodel)
        {
            if (ModelState.IsValid)
            {
                //Server.HtmlEncode(postermodel.Text);
                postermodel.PostTime   = DateTime.Now;
                postermodel.ModifyTime = DateTime.Now;
                postermodel.UserId     = new UsersContext().UserProfiles.Single(u => u.UserName == User.Identity.Name).UserId;
                db.Posters.Add(postermodel);


                db.SaveChanges();
                //return RedirectToAction("Index");
                return(RedirectToAction("Details/" + postermodel.Id));
            }

            //return View(postermodel);
            return(RedirectToAction("Details/" + postermodel.Id));
        }
示例#10
0
        public IActionResult Poster(string posterId)
        {
            ObjectId posterOId;

            if (!ObjectId.TryParse(posterId, out posterOId))
            {
                return(NotFound());
            }

            var posters    = _mongoDB.GetCollection <BsonDocument>("posters");
            var posterBson = posters.Find($"{{ _id: ObjectId('{posterId}') }}").FirstOrDefault();

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

            PosterModel poster = BsonSerializer.Deserialize <PosterModel>(posterBson);

            return(File(poster.Image, "image/jpeg"));
        }
示例#11
0
        public IActionResult Index(PosterModel model)
        {
            string originalImage = Path.Combine(webrootPath, "images", "large_Event_Poster_Pasta.png");
            string newFilePath   = Path.Combine(webrootPath, "images", "poster_with_data.png");
            string pdffile       = Path.Combine(webrootPath, "images", "poster_with_data.pdf");
            string font          = Path.Combine(webrootPath, "fonts", "TGSharpSans-Medium.ttf");
            string extraBoldFont = Path.Combine(webrootPath, "fonts", "TGSharpSans-Semibold.ttf");
            string thinFont      = Path.Combine(webrootPath, "fonts", "TGSharpSans-Thin.ttf");

            using (MagickImage image = new MagickImage(originalImage)) {
                // image.Draw(drawables);
                var readSettings = new MagickReadSettings {
                    FillColor       = MagickColors.Black,
                    BackgroundColor = MagickColors.Transparent,
                    // TextGravity = Gravity.Center,
                    Width         = 400,
                    StrokeColor   = MagickColors.Black,
                    Font          = extraBoldFont,
                    FontPointsize = 36,
                };
                using (var caption = new MagickImage($"caption: {model.EventName.Replace('~','\n').ToUpper()}", readSettings)) {
                    image.Composite(caption, 100, 500, CompositeOperator.Over);
                }
                readSettings.Font = font;
                using (var caption = new MagickImage($"caption: {model.EventDate.Replace('~', '\n').ToUpper()}", readSettings)) {
                    image.Composite(caption, 100, 600, CompositeOperator.Over);
                }
                readSettings.FontPointsize = 18;
                using (var caption = new MagickImage($"caption: {model.Location.Replace('~', '\n').ToUpper()}", readSettings)) {
                    image.Composite(caption, 100, 650, CompositeOperator.Over);
                }

                DrawableLine line = new DrawableLine(100, 700, 600, 700);
                image.Draw(line);
                readSettings.FontPointsize = 14;
                readSettings.Width         = 200;
                readSettings.Font          = thinFont;
                using (var caption = new MagickImage($"caption: {model.Explanation}", readSettings)) {
                    image.Composite(caption, 100, 725, CompositeOperator.Over);
                }
                using (var caption = new MagickImage($"caption: {model.AdditionalDetails}", readSettings)) {
                    image.Composite(caption, 400, 725, CompositeOperator.Over);
                }

                //var eventNameDrawable = new Drawables()
                //    .Font(@"H:\publicH\Downloads\TenderGreensSharpSans-Extrabold.woff2",FontStyleType.Bold,FontWeight.Bold, FontStretch.Normal)
                //    .FontPointSize(72)

                //    .StrokeColor(MagickColors.Black)
                //    .Text(100,600, model.EventName.ToUpper())

                //    .Draw(image);


                //var drawable = new Drawables()
                //    //.FontPointSize(72)
                //    //.Font(extraBoldFont)
                //    //.StrokeColor(MagickColors.Black)
                //    //.TextAlignment(TextAlignment.Left)
                //   // .Text(100, 600, model.EventName.ToUpper())
                //     .FontPointSize(36)
                //    .Font(font)
                //    .StrokeColor(MagickColors.Black)
                //    .TextAlignment(TextAlignment.Left)
                //    .Text(100, 700, model.EventDate.ToUpper())
                //    .Text(100, 800, model.Location.ToUpper())
                //    //.StrokeColor(new MagickColor(0, Quantum.Max, 0))
                //    //.FillColor(MagickColors.SaddleBrown)
                //    //.Ellipse(256, 96, 192, 8, 0, 360)
                //    .Draw(image);
                image.Write(newFilePath);
                model.ImageSrc = "/images/poster_with_data.png";
                image.Write(pdffile);
                //ExifProfile profile = image.GetExifProfile();
                //if (profile == null) {
                //    ViewData["Message"] = "Image does not contain exif information";
                //}
                //else {
                //    string message = "";
                //    foreach (ExifValue value in profile.Values) {
                //        message += $"{value.Tag} ({value.DataType}): {value.ToString()}<br />";
                //    }
                //}
            }

            return(View(model));
        }