Example #1
0
 public ActionResult Edit(Mosaic mosaic)
 {
     if (ModelState.IsValid)
     {
         db.Mosaics.Attach(mosaic);
         db.ObjectStateManager.ChangeObjectState(mosaic, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(mosaic);
 }
Example #2
0
    public ActionResult Create(Mosaic mosaic)
    {
        if (ModelState.IsValid)
        {
            db.Mosaics.AddObject(mosaic);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        return View(mosaic);
    }
Example #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Mosaics EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMosaics(Mosaic mosaic)
 {
     base.AddObject("Mosaics", mosaic);
 }
Example #4
0
 /// <summary>
 /// Create a new Mosaic object.
 /// </summary>
 /// <param name="mosaicID">Initial value of the MosaicID property.</param>
 /// <param name="created">Initial value of the Created property.</param>
 /// <param name="updated">Initial value of the Updated property.</param>
 /// <param name="width">Initial value of the Width property.</param>
 /// <param name="height">Initial value of the Height property.</param>
 /// <param name="size">Initial value of the Size property.</param>
 public static Mosaic CreateMosaic(global::System.Int64 mosaicID, global::System.DateTime created, global::System.DateTime updated, global::System.Int32 width, global::System.Int32 height, global::System.Int64 size)
 {
     Mosaic mosaic = new Mosaic();
     mosaic.MosaicID = mosaicID;
     mosaic.Created = created;
     mosaic.Updated = updated;
     mosaic.Width = width;
     mosaic.Height = height;
     mosaic.Size = size;
     return mosaic;
 }
Example #5
0
        public ActionResult EditPartial(Mosaic mosaic)
        {
            if (ModelState.IsValid)
            {
                if (!String.IsNullOrEmpty(mosaic.Background))
                {
                    var name = Path.GetFileName(mosaic.Background).Replace("/eAd.Website", "").Replace("Thumb", "");
                    var media = db.Media.Where(m => m.Location.Contains(name)).Single();
                    mosaic.Background = media.Location;

                }
                mosaic.Updated = DateTime.Now;

                var mosaicToSave = db.Mosaics.Where(m => m.MosaicID == mosaic.MosaicID).SingleOrDefault();
                if (mosaicToSave != null)
                {
                    mosaicToSave.Name = mosaic.Name;
                    mosaicToSave.Background = mosaic.Background;
                    mosaicToSave.Updated = mosaic.Updated;
                    mosaicToSave.Width = mosaic.Width;
                    mosaicToSave.Height = mosaic.Height;
                }


                //   db.Mosaics.Attach(mosaic);
             //   db.ObjectStateManager.ChangeObjectState(mosaic, EntityState.Modified);
                db.SaveChanges();
                return Json("Successfully Saved Mosaic");
            }
            return Json("Please Check your inputs and save again");
        }
Example #6
0
        public ActionResult CreateProfile(string name)
        {

            Mosaic mosaic = new Mosaic();
            mosaic.Name = name;
            mosaic.Created = DateTime.Now;
            mosaic.Updated = DateTime.Now;

            mosaic.Width = 768;
            mosaic.Height = 1366;
            mosaic.Type = "Profile";
            db.Mosaics.AddObject(mosaic);
            db.SaveChanges();

            return Json(new { message = "Mosaic Created" }, JsonRequestBehavior.AllowGet);

        }
Example #7
0
        private static void UpdateMosaicCache(Mosaic mosaic, string mosaicCache)
        {

            FileUtilities.FolderCreate(Path.GetDirectoryName(mosaicCache));

            File.Delete(mosaicCache);

            using (var filestream = new FileStream(mosaicCache, FileMode.CreateNew))
            {
                LayoutModel model = new LayoutModel();


                model.Background = mosaic.Background;
                model.Bgcolor = mosaic.BackgroundColor;
                model.Height = (int)mosaic.Height;
                model.Width = (int)mosaic.Width;
                model.SchemaVersion = 1;
                model.Tags = new List<LayoutTags>();
                model.Type = mosaic.Type;
                model.Regions = new List<LayoutRegion>();

                if (model.Type == "Profile")
                {
                    //Load Data
                    XmlSerializer xserializer = new XmlSerializer(typeof(List<PositionViewModel>));
                    var extraItems =
                        (xserializer.
                        Deserialize(new StringReader(mosaic.ExtraData))
                        as List<PositionViewModel>).Select(position => new LayoutRegion
                    {
                        Height = (int)position.Height,
                        Width = (int)position.Width,
                        Left = (int)position.X,
                        Top = (int)position.Y,
                        Type = "Widget",
                        Name = position.Name,
                        Media = new List<LayoutRegionMedia>(){new LayoutRegionMedia()
                    {
                        Duration = 1000000,
                        Id = (-1).ToString(),
                        Lkid = -1,
                        Options = new LayoutRegionMediaOptions()
                        {
                            Uri = "None"
                        },
                        Raw = new LayoutRegionMediaRaw()
                        {
                           
                        },

                        SchemaVersion = 1,
                        Type = "PlaceHolder",
                        UserId =0
                    }}
                    });

                    model.Regions.AddRange(extraItems);

                }

                foreach (var position in mosaic.Positions)
                {



                    model.Regions.Add(new LayoutRegion
                    {
                        Height = (int)position.Height,
                        Width = (int)position.Width,
                        Id = position.PositionID.ToString(),
                        Left = (int)position.X,
                        Top = (int)position.Y,
                        UserId = (int)position.UserID,
                        Media = position.Media.Select(medium => new LayoutRegionMedia()
                        {
                            Duration = (int) medium.Duration.Value.TotalSeconds,
                            Id = medium.MediaID.ToString(),
                            Lkid = (int)medium.MediaID,
                            Options = new LayoutRegionMediaOptions()
                            {
                                Uri = medium.Location
                            },
                            Raw = new LayoutRegionMediaRaw()
                            {
                            },

                            SchemaVersion = 1,
                            Type = medium.Type=="Powerpoint"?"Video":medium.Type,
                            UserId = (int)medium.UserID
                        }).ToList()
                    });
                }


                XmlSerializer serializer = new XmlSerializer(typeof(LayoutModel));
                serializer.Serialize(filestream, model);
                filestream.Position = 0;
                mosaic.Hash = Hashes.MD5(filestream);
            }

            mosaic.Size = new FileInfo(mosaicCache).Length;


        }