public ActionResult Edit([Bind(Include = "id,title,previd,created,modified")] AlbumViewModel albumModel, int?language_id) { if (ModelState.IsValid) { DateTime date = DateTime.Now; albumModel.modified = date; if (language_id != null) { albumModel.language_id = language_id; } Mapper.Initialize(cfg => cfg.CreateMap <AlbumViewModel, Albums>()); Albums album = Mapper.Map <AlbumViewModel, Albums>(albumModel); albumHandler.Update(album); return(RedirectToAction("Index")); } ViewBag.language_id = new SelectList(languageHandler.All(). Select(c => new { id = c.id, title = c.title }), "id", "title"); ViewBag.language = languageHandler.All(); return(View(albumModel)); }
/// <summary> /// Updates the Album by the ablum ID /// </summary> /// <param name="album">Desired changes</param> public static void Update(Album album) { IAlbum userResource = Resource.GetResource <IAlbum>(); userResource.Update(album); }
/// <summary> /// 更新数据 Update(AlbumInfo entity) /// </summary> /// <param name="entity">实体类(AlbumInfo)</param> ///<returns>true:保存成功; false:保存失败</returns> public bool Update(AlbumInfo entity) { return(_album.Update(entity)); }