Esempio n. 1
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;
        }
Esempio n. 2
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 });
        }