Exemple #1
0
        public ActionResult Reject(int id, int?currentCategoryId, OrderSorts ordersSort)
        {
            var pictureId = _userService.FindById(id).PictureId;

            _orderService.DeleteOrder(id);
            _pictureService.Delete(pictureId);
            _unitOfWork.Save();
            return(RedirectToAction("Index", new
            {
                newApplications = _orderService.GetAll().Count(o => !o.AdminStatus) > 0,
                categoryId = currentCategoryId,
                sort = ordersSort
            }));
        }
        public JsonResult PicDelete(long productID, long picID)
        {
            JsonResult result = new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            if (picID == 0)
            {
                return(result);
            }
            else
            {
                ProductPicture _PicModel = svc.SelectOrEmpty(
                    new ProductPictureQuery()
                {
                    IDs = new long[] { picID }
                }).FirstOrDefault();
                if (_PicModel != null)
                {
                    _pictureService.Delete(_PicModel);
                    svc.Delete(_PicModel);
                    result.Data = new { Success = true };
                }
                else
                {
                    result.Data = new { Success = false };
                }
                return(result);
            }
        }
        public void Delete(int id)
        {
            var profile = GetByProfileId(id);

            if (profile.Pictures.Any())
            {
                var tempPictures = profile.Pictures.Select(x => new { Id = x.PictureId, Path = x.Path, FileName = x.FileName }).ToList();
                foreach (var pic in tempPictures)
                {
                    PictureService.Delete(pic.Path, pic.FileName);
                    PictureRepository.Delete(pic.Id);
                }
            }

            if (profile.Grunkers.Any())
            {
                var tempGrunks = profile.Grunkers.Select(x => x.GrunkId).ToList();
                foreach (var grunkId in tempGrunks)
                {
                    GrunkRepository.Delete(grunkId);
                }
            }

            if (profile.Purchases.Any())
            {
                var tempPurchases = profile.Purchases.Select(x => new { x.AlbumId, x.ProfileId }).ToList();
                foreach (var purchase in tempPurchases)
                {
                    ProductService.DeletePurchase(purchase.AlbumId, purchase.ProfileId);
                }
            }

            if (profile.ProfileActivities.Any())
            {
                var tempActivities = profile.ProfileActivities.ToList();
                foreach (var activityId in tempActivities)
                {
                    ProfileActivityRepository.Delete(activityId.ActivityId);
                }
            }

            ReviewService.DeleteByProfileId(id);

            ProfileRepository.Delete(id);

            CredentialService.DeleteById(profile.CredentialsId);
        }
Exemple #4
0
        private void DeletePictures(Review review)
        {
            var tempPictures = review.Pictures.Select(x => new { Id = x.PictureId, Path = x.Path, FileName = x.FileName }).ToList();

            foreach (var pic in tempPictures)
            {
                PictureService.Delete(pic.Path, pic.FileName);
                PictureRepository.Delete(pic.Id);
            }
        }
Exemple #5
0
        public ActionResult DeletePicture(int pictureid)
        {
            if (pictureid == 0)
            {
                throw new Exception("Picture id missing.");
            }

            var picture = _pictureService.GetPictureById(pictureid);

            if (picture != null)
            {
                _pictureService.Delete(pictureid);
            }

            return(Json(new
            {
                success = true,
            }, "text/plain"));
        }
Exemple #6
0
        public IActionResult Delete(int id)
        {
            var deletePicture = _pictureService.GetById(id);

            if (deletePicture != null)
            {
                _pictureService.Delete(deletePicture);
            }
            return(RedirectToAction(nameof(Index)));
        }
        public Album Update(int id, string albumName, string artistName, int genreId, Int16 price, System.Web.HttpPostedFileBase cover)
        {
            Album album = AlbumRepository.Update(id, price, genreId, albumName, artistName);

            if (cover != null)
            {
                var tempPictures = album.Pictures.Select(x => new { Id = x.PictureId, Path = x.Path, FileName = x.FileName }).ToList();
                foreach (var pic in tempPictures)
                {
                    PictureService.Delete(pic.Path, pic.FileName);
                    PictureRepository.Delete(pic.Id);
                }

                UploadResizeAndSave(ref album, cover);
            }



            return(album);
        }
        public async Task <ActionResult> DeleteAccount(DeleteAccountViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = _userService.FindById(User.Identity.GetUserId <int>());

                var picture = _userService.FindById(user.Id).PictureId;
                if (picture.HasValue)
                {
                    _pictureService.Delete(picture.Value);
                }

                var ordersId = _orderService.GetAll().Where(o => o.UserId == user.Id).Select(o => o.Id).ToList();
                if (ordersId.Any())
                {
                    var responses = _responseService.GetAll()
                                    .Select(r => r.OrderId.Value)
                                    .Where(r => ordersId.Contains(r)).ToList();
                    if (responses.Any())
                    {
                        foreach (var response in responses)
                        {
                            _responseService.Delete(response);
                        }
                    }
                }

                var comments = _commentService.GetAll().Where(c => c.CustomerId == user.Id).ToList();
                if (comments.Any())
                {
                    foreach (var comment in comments)
                    {
                        _commentService.Delete(comment.Id);
                    }
                }

                ClientViewModelBLL userDto = new ClientViewModelBLL
                {
                    Password = model.Password,
                    Email    = User.Identity.Name
                };
                var operationDetails = await _userService.DeleteAccount(userDto);

                if (operationDetails.Succedeed)
                {
                    _unitOfWork.Save();
                    LogOff();
                    return(RedirectToAction("Index", "Home"));
                }

                ModelState.AddModelError(operationDetails.Property, operationDetails.Message);
            }
            return(View(model));
        }
Exemple #9
0
        public ActionResult Reject(int id, int?currentCategoryId, PerformerSorts performersSort)
        {
            var pictureId = _userService.FindById(id).PictureId;

            _userService.RejectPerformer(id);
            _pictureService.Delete(pictureId);
            _unitOfWork.Save();
            return(RedirectToAction("Index", new
            {
                newApplications = _userService.GetAll().Count(u => !u.AdminStatus && u.IsPerformer) > 0,
                categoryId = currentCategoryId,
                sort = performersSort
            }));
        }
Exemple #10
0
        public virtual void DeleteSliderPictures(Slider slider, IList <Picture> pictures)
        {
            if (pictures == null)
            {
                throw new ArgumentNullException("pictures");
            }

            foreach (var _picture in pictures)
            {
                slider.Pictures.Remove(_picture);
                _sliderRepository.Update(slider);
                _pictureService.Delete(_picture.Id);
            }
        }
Exemple #11
0
        public ActionResult DeleteNewsPicture(int id)
        {
            if (!_permissionService.Authorize("ManageNews"))
            {
                return(AccessDeniedView());
            }

            if (id == 0)
            {
                throw new Exception("Picture id not found");
            }

            var pictureRecord = _pictureService.GetNewsPictureByPictureId(id);

            if (pictureRecord != null)
            {
                _pictureService.DeleteNewsPicture(pictureRecord.Id);
            }
            else
            {
                var picture = _pictureService.GetPictureById(id);
                if (picture != null)
                {
                    _pictureService.Delete(picture.Id);
                }
            }

            SuccessNotification("News picture deleted successfully");
            return(new JsonResult()
            {
                Data = true,
                ContentEncoding = Encoding.Default,
                ContentType = "application/json",
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                MaxJsonLength = int.MaxValue
            });
        }
        public virtual ActionResult DeletePicture(long?id)
        {
            if (id == null)
            {
                return(Content(null));
            }
            var picture = _pictureService.GetById(id.Value);

            if (picture == null)
            {
                return(HttpNotFound());
            }
            _pictureService.Delete(id.Value);

            if (System.IO.File.Exists(Server.MapPath("~/Uploads/" + picture.Path)))
            {
                System.IO.File.Delete(Server.MapPath("~/Uploads/" + picture.Path));
            }
            return(Content("ok"));
        }
        public JsonResult DeletePic(int id)
        {
            var pic = Service.Select(new PictureResourceQuery()
            {
                IDs = new long[] { id }
            }).FirstOrDefault();

            if (pic != null)
            {
                ResourcePictureService.Delete(pic);
                Service.Delete(new PictureResource {
                    ID = id
                });
            }
            return(new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { success = true },
            });
        }
        public ActionResult PicDelete(long picID)
        {
            JsonResult result = new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            try
            {
                //删除物理文件
                BannerPicture _PicModel = svc.SelectOrEmpty(new BannerPictureQuery()
                {
                    IDs = new long[] { picID }
                }).FirstOrDefault();
                _pictureService.Delete(_PicModel);

                //删除数据库记录
                svc.Delete(new BannerPicture()
                {
                    ID = picID
                });

                result.Data =
                    new
                {
                    Success = true
                };

                return(result);
            }
            catch (Exception e)
            {
                result.Data =
                    new
                {
                    Success = false,
                    Message = e.Message
                };

                return(result);
            }
        }
 public IHttpActionResult Delete(int id)
 {
     pictureService.Delete(id);
     return(Ok());
 }
Exemple #16
0
        public async Task <ActionResult <Picture> > Delete(Guid id)
        {
            await _service.Delete(id);

            return(NoContent());
        }