Exemplo n.º 1
0
 // PUT: api/Picture/5
 public void Put(int id, [FromBody] UpdatePicture update)
 {
     if (id == update.ID)
     {
         manager.Update(update);
     }
 }
Exemplo n.º 2
0
        void IDataSender.UpdatePicture(UpdatePicture update)
        {
            Datagram datagram = new Datagram
            {
                DataType    = DatagramType.Login,
                MessageType = LoginMessageType.UpdatePicture,
                Datas       = update.ToByteArray()
            };

            if (!Send(datagram))
            {
                RunningDatas.InfoNotify("网络连接失败 请重启软件后重试");
            }
        }
Exemplo n.º 3
0
        private async void BtnUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (LvAll.SelectedItem != null)
            {
                var p = await AdminInterface.GetAsync((LvAll.SelectedItem as PictureInfo).Id);

                var update = new UpdatePicture(AdminInterface)
                {
                    Picture = p
                };
                update.ShowDialog();
            }
            else
            {
                popup        = ConfigurePopup.Configure(popup, "Select an item first!", BtnListAll, PlacementMode.Bottom);
                popup.IsOpen = true;
                return;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 窗体的构造函数
        /// </summary>
        public FormClient()
        {
            InitializeComponent();
            chessPanel = new ChessPanel();
            this.splitContainer2.Panel1.Controls.Add(this.chessPanel);
            chessPanel.BringToFront();
            //chesspanel的设置
            this.chessPanel.BackColor             = System.Drawing.Color.DarkOrange;
            this.chessPanel.BackgroundImage       = global::Client.Resource.back;
            this.chessPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            this.chessPanel.Dock        = System.Windows.Forms.DockStyle.Fill;
            this.chessPanel.Location    = new System.Drawing.Point(0, 67);
            this.chessPanel.MinimumSize = new System.Drawing.Size(100, 100);
            timer1.Stop();

            updataPic = new UpdatePicture(UpDatePicture);
            delStep   = new StepsChangeHandler(SetStepsOnLabel);
            delHelp   = new HelpHandler(SetHelpOnLabel);
            delPP     = new PPHandler(SetPPInfo);
        }
Exemplo n.º 5
0
        public void Update(UpdatePicture input)
        {
            Picture output = Mapper.Map <UpdatePicture, Picture>(input);

            _pictureManager.Update(output);
        }
Exemplo n.º 6
0
        private void OnUpdatePicture(Datagram datagram)
        {
            UpdatePicture update = datagram.UnSerialData <UpdatePicture>();

            SQLDB.UpdateProfilePhoto(update.UserID, update.UserPicture);
        }
Exemplo n.º 7
0
 public void Update(UpdatePicture input)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
        public object Put(UpdatePicture request)
        {
            try
            {
                var token = AuthService.CheckPermitions(Request.Headers["Authorization"], Db);
                if (token == null)
                    return HttpError.Unauthorized("Please, authorize");

                var picture = Db.GetByIdOrDefault<Picture>(request.Id);
                if (picture == null)
                    return HttpError.NotFound($"Picture '{request.Id}' does not exist");

                Mapper.Map(request, picture, opts => opts.AfterMap((rq, pic) => pic.Id = rq.Id));

                var galInfo = request.Gallery.Split(new[] {", "}, StringSplitOptions.RemoveEmptyEntries);

                picture.MaterialId = Db.Select<Material>(x => x.Name == request.Material).First().Id;
                picture.GalleryId = Db.Select<Gallery>(x => x.Name == galInfo.ElementAtOrDefault(0) && x.City == galInfo.ElementAtOrDefault(1)).FirstOrDefault()?.Id;
                picture.TechniqueId = Db.Select<Technique>(x => x.Name == request.Technique).First().Id;

                Db.Update(picture);

                if (request.Artists.Any())
                {
                    var pba = Db.Select<PicturesByArtist>().Join(request.Artists, x => x.ArtistId, a => a.Id, (x, _) => x).ToList();

                    Db.DeleteAll(pba);

                    Db.SaveAll(pba.Select(x => new PicturesByArtist { ArtistId = x.ArtistId, PictureId = picture.Id }));
                    Db.SaveAll(request.Artists.Select(x => new PicturesByArtist { ArtistId = x.Id, PictureId = picture.Id }).ExceptBy(pba, o => o.ArtistId).ToList());
                }
                if (request.Genres.Any())
                {
                    var abp = Db.Select<Genre>()
                        .Join(request.Genres, x => x.Name, x => x, (x, _) => x.Id)
                        .Join(Db.Select<PicturesByGenre>(), x => x, x => x.GenreId, (_, p) => p)
                        .ToList();

                    Db.Delete(abp);
                    Db.SaveAll(abp.Select(x => new PicturesByGenre { GenreId = x.GenreId, PictureId = picture.Id }));
                }

                return new HttpResult(picture, $"{MimeTypes.Json}; charset=utf-8")
                {
                    StatusCode = OK
                };
            }
            catch
            {
                return new HttpError(InternalServerError, "Internal Server Error");
            }
        }