Exemplo n.º 1
0
        public ActionResult AddAlbom(AlbomListItem albom)
        {
            if (!ModelState.IsValid || !ConfigurationManager.CanCreateAlboms)
            {
                if (unitOfWork.AlbomRepository.GetAlbomByName(albom.AlbomName) != null)
                {
                    ModelState.AddModelError("", "Albom name must be unique!");
                }
                if (!ConfigurationManager.CanCreateAlboms)
                {
                    ModelState.AddModelError("", "You've got an albom limit!");
                }
                return View("AddAlbom", albom);
            }

            var newAlbom = new Albom()
            {
                AlbomName = albom.AlbomName,
                AlbomDescription = albom.Description,
                AlbomOwner = (new UserManager()).GetUserByName(User.Identity.Name).UserId
            };

            unitOfWork.AlbomRepository.Insert(newAlbom);
            unitOfWork.AlbomRepository.Save();

            return View("Index", unitOfWork.AlbomRepository.GetAlbomByUser(User.Identity.Name).ToList());
        }
 /// <summary>
 /// Create a new Albom object.
 /// </summary>
 /// <param name="albomId">Initial value of the AlbomId property.</param>
 /// <param name="albomName">Initial value of the AlbomName property.</param>
 /// <param name="albomOwner">Initial value of the AlbomOwner property.</param>
 public static Albom CreateAlbom(global::System.Int32 albomId, global::System.String albomName, global::System.Int32 albomOwner)
 {
     Albom albom = new Albom();
     albom.AlbomId = albomId;
     albom.AlbomName = albomName;
     albom.AlbomOwner = albomOwner;
     return albom;
 }
Exemplo n.º 3
0
        public ViewResult EditAlbom(AlbomListItem model)
        {
            if (ModelState.IsValid)
            {
                Albom albom = new Albom();

                albom.AlbomName = model.AlbomName;
                albom.AlbomId = model.AlbomId;
                albom.AlbomOwner = model.Owner;
                albom.AlbomDescription = model.Description;

                unitOfWork.AlbomRepository.Update(albom);
                unitOfWork.AlbomRepository.Save();
            }

            return View("EditAlbom", model);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Alboms EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAlboms(Albom albom)
 {
     base.AddObject("Alboms", albom);
 }