Ejemplo n.º 1
0
        public ActionResult CreateAlbum(AlbumModel model)
        {
            if (ModelState.IsValid)
            {
                try {
                    Entities dbContext = new Entities();

                    Models.Object obj = new Models.Object();
                    obj.EntityName = "Album";
                    dbContext.Objects.AddObject(obj);
                    dbContext.SaveChanges();

                    Album album = new Album();
                    album.Id = obj.Id;
                    album.UserId = new Guid(UserHelper.getLoggedInUserId());
                    album.Name = model.Name;
                    album.Description = model.Description;
                    album.CreatedAt = DateTime.Now;

                    dbContext.Albums.AddObject(album);

                    dbContext.SaveChanges();

                    return RedirectToAction("Upload", "Photo");

                }catch(Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }
            return View(model);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a new Album object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 /// <param name="createdAt">Initial value of the CreatedAt property.</param>
 public static Album CreateAlbum(global::System.Int32 id, global::System.String name, global::System.Guid userId, global::System.DateTime createdAt)
 {
     Album album = new Album();
     album.Id = id;
     album.Name = name;
     album.UserId = userId;
     album.CreatedAt = createdAt;
     return album;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Albums EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAlbums(Album album)
 {
     base.AddObject("Albums", album);
 }