Exemplo n.º 1
0
        public ActionResult UploadBigPhoto(long id, HttpPostedFileBase photoFile)
        {
            try
            {
                if (photoFile != null)
                {
                    if (photoFile.ContentLength > 0)
                    {
                        var path = UploadPhoto(id, photoFile);
                        if (!string.IsNullOrEmpty(path))
                        {
                            var pho = new PhotoBig()
                            {
                                name = string.Empty, path = path, skuId = id
                            };
                            if (dataService.AddBigPhotoToSKU(id, pho))
                            {
                                return(RedirectToAction("SkuData", "Admin", new { id = id }));
                            }
                        }
                    }
                }
                else
                {
                    return(Content("Фото НЕ сохранено ", "text/html"));
                }
            }
            catch (Exception err)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Content("Фото НЕ сохранено " + err, "text/html"));
            }

            return(RedirectToAction("SkuData", "Admin", new { id = id }));
        }
Exemplo n.º 2
0
 public override void ToStream(Stream output)
 {
     output.Write(TLUtils.SignatureToBytes(Signature));
     output.Write(PhotoId != null ? PhotoId.ToBytes() : new TLLong(0).ToBytes());
     PhotoSmall.ToStream(output);
     PhotoBig.ToStream(output);
 }
Exemplo n.º 3
0
        public bool AddBigPhotoToSKU(long id, PhotoBig photo)
        {
            var result = false;

            try
            {
                dbService.Run(db =>
                {
                    var sku = db.GetRepository <Sku>().TryOne(id);
                    if (sku != null)
                    {
                        if (sku.listPhoto == null)
                        {
                            sku.listPhoto = new List <PhotoBig>();
                        }

                        sku.listPhoto.Add(new PhotoBig()
                        {
                            name = photo.name, path = photo.path, skuId = sku.id
                        });
                        db.GetRepository <Sku>().Update(sku);
                        result = true;
                    }
                });
            }
            catch (Exception err)
            {
                result = false;
                logger.Error(err.Message);
            }

            return(result);
        }
Exemplo n.º 4
0
        public override void Update(TLChatPhotoBase photo)
        {
            var photoCommon = photo as TLChatPhoto;

            if (photoCommon != null)
            {
                if (PhotoSmall != null)
                {
                    PhotoSmall.Update(photoCommon.PhotoSmall);
                }
                else
                {
                    PhotoSmall = photoCommon.PhotoSmall;
                }
                if (PhotoBig != null)
                {
                    PhotoBig.Update(photoCommon.PhotoBig);
                }
                else
                {
                    PhotoBig = photoCommon.PhotoBig;
                }
            }
        }
Exemplo n.º 5
0
 public override void ToStream(Stream output)
 {
     output.Write(TLUtils.SignatureToBytes(Signature));
     PhotoSmall.ToStream(output);
     PhotoBig.ToStream(output);
 }