Пример #1
0
        public ActionResult Add(Album album)
        {
            HttpPostedFileBase file = Request.Files["albumimage"];

            if (Session["UID"] != null)
            {
                if (ModelState.IsValid)
                {
                    if (file != null)
                    {
                        string filePath     = file.FileName;
                        string fileName     = filePath.Substring(filePath.LastIndexOf("\\") + 1);
                        string serverpath   = Server.MapPath(@"\images\albums\") + fileName;
                        string relativepath = @"/images/albums/" + fileName;
                        file.SaveAs(serverpath);
                        album.Alb_Pic = relativepath;
                    }
                    album.UID      = Convert.ToInt32(Session["UID"].ToString());
                    album.Alb_Time = DateTime.Now;
                    albumm.Add(album);
                    return(Content("<script>alert('添加成功!');window.open('" + Url.Action("Index", "Album") + "','_self');</script>"));
                }
            }
            else
            {
                return(Content("<script>;alert('你还没有登陆哦!');history.go(-1)</script>"));
            }
            return(View(album));
        }
Пример #2
0
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnSave_OnClick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(StrGuid))
            {
                var info = new AlbumInfo();

                info.Name    = tbName.Text;
                info.OrderId = ConvertHelper.GetInt(tbOrderId.Text);
                var user = HttpContext.Current.Session["UserInfo"] as UserInfo;
                if (user != null)
                {
                    info.UserGuid = user.Guid;
                }
                var blog = HttpContext.Current.Session["BlogInfo"] as BlogInfo;
                if (blog != null)
                {
                    info.BlogGuid = blog.Guid;
                }
                info.CreateTime = DateTime.Now;

                AlbumBll.Add(info);
            }
            else
            {
                var info = AlbumBll.GetModel(StrGuid);
                info.Name    = tbName.Text;
                info.OrderId = ConvertHelper.GetInt(tbOrderId.Text);

                AlbumBll.Update(info);
            }

            Response.Redirect("AlbumList.aspx");
        }
Пример #3
0
 /// <summary>
 /// Method to add new <see cref="AlbumEntity"/>.
 /// </summary>
 /// <param name="entity">The <see cref="AlbumEntity"/>.</param>
 /// <returns>The new <see cref="AlbumEntity"/>.</returns>
 public AlbumEntity Add(AlbumEntity entity)
 {
     using (Db.Context)
     {
         return(AlbumManager.Add(entity));
     }
 }
Пример #4
0
        public ActionResult AddItem(string id, string movie, string note, string returnurl)
        {
            AlbumItemViewModel item = new AlbumItemViewModel();

            item.Movie = movie;
            item.Note  = note;
            item.Time  = DateTime.Now.ToString();
            AlbumManager.Add(id, item);
            return(RedirectToLocal(returnurl));
        }
 public MainWindow()
 {
     InitializeComponent();
     FolderViewLoadFoldersAndDrives();
     albumManager = new AlbumManager();
     album        = albumManager.GetLastAlbum();
     if (album == null)
     {
         album = new Album();
         albumManager.Add(album);
     }
     UpdateGUI();
 }
        /// <summary>
        /// New album
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemNew_Click(object sender, RoutedEventArgs e)
        {
            // Open dialog to rename with current name
            RenameDialog renameDialog = new RenameDialog(string.Empty, "Rename", "Album");

            // If renamed
            if (renameDialog.ShowDialog() == true)
            {
                // Set new name and update list
                album = new Album(renameDialog.Name);
                albumManager.Add(album);
                UpdateGUI();
            }
        }
Пример #7
0
        public IHttpActionResult Create([FromBody] AlbumPostModel model)
        {
            var userId = Request.GetUserId();

            if (userId < 0)
            {
                return(Unauthorized());
            }

            if (model == null)
            {
                return(BadRequest("Model cannot be null"));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var album = Mapper.Map <Album>(model);

            album.RowState  = RowState.Created;
            album.CreatedBy = userId;
            album.CreatedAt = DateTime.Now;

            _albumManager.Add(album);

            foreach (var photoModel in model.Photos)
            {
                var photo = Mapper.Map <Photo>(photoModel);

                photo.AlbumId    = album.Id;
                photo.RowState   = RowState.Created;
                photo.UploadedAt = DateTime.Now;
                photo.UploadedBy = userId;

                _photoManager.Add(photo);
            }

            return(Created($"/{album.Id}", Mapper.Map <AlbumViewModel>(album)));
        }