Exemple #1
0
        public ActionResult MakePolygraphyOrder(int?id)
        {
            try
            {
                AdvertisingDTO ad    = orderService.GetAdvertising(id);
                var            order = new PolygraphyViewModel {
                    AdvertisingID = ad.ID
                };

                return(View(order));
            }
            catch (ValidationException ex)
            {
                return(Content(ex.Message));
            }
        }
Exemple #2
0
        public OperationDetails RemoveAdvertising(AdvertisingDTO adDTO)
        {
            var ad = _db.Advertising.Find(p => p.ImageId.Equals(adDTO.ImageId)).FirstOrDefault();

            if (ad != null)
            {
                _db.Advertising.Remove(ad);  //удаляю по id т.к при нахождении рекламы я получаю не все данный, а для удаления по сущности нужны все...
                _db.Save();
                int countAd = _db.Advertising.CountWithExpressionTree(p => p.User.Id.Equals(adDTO.OwnerId));
                if (countAd < 1)
                {
                    _db.UserManager.RemoveFromRoles(adDTO.OwnerId, "moderatorAdvertising");
                }
                return(new OperationDetails(true, "", ""));
            }
            return(new OperationDetails(false, "не найдена реклама с таким id пользователя или id рекламного места", ""));
        }
Exemple #3
0
        public async Task <IActionResult> EditAdvertising([FromForm] AdvertisingDTO request)
        {
            try
            {
                if (request.Id <= 0)
                {
                    return(StatusCode((int)System.Net.HttpStatusCode.BadRequest, "Id not found!"));
                }
                else if (String.IsNullOrEmpty(request.TitleEn))
                {
                    return(StatusCode((int)System.Net.HttpStatusCode.BadRequest, "English Title Not Found!"));
                }
                else if (String.IsNullOrEmpty(request.TitleAr))
                {
                    return(StatusCode((int)System.Net.HttpStatusCode.BadRequest, "Arabic Title Not Found!"));
                }
                else if (String.IsNullOrEmpty(request.DescriptionEn))
                {
                    return(StatusCode((int)System.Net.HttpStatusCode.BadRequest, "English Description Not Found!"));
                }
                else if (String.IsNullOrEmpty(request.DescriptionAr))
                {
                    return(StatusCode((int)System.Net.HttpStatusCode.BadRequest, "Arabic Description Not Found!"));
                }
                else
                {
                    var result = await _advertisingRepo.UpdateAsync(request, request.File);

                    if (result != null)
                    {
                        return(Ok(result));
                    }
                    else
                    {
                        return(NoContent());
                    }
                }
            }
            catch (Exception ex)
            {
                return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError, ex.Message));
            }
        }