Beispiel #1
0
        public IActionResult AddContent(ListPetitionDetailDto petitionDetailDto)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Detail", "Petition"));
            }


            var checkContents = _contentService.ListContents(petitionDetailDto.Petition.PetitionID).Take(2).ToList();

            //SPAM KONTROLÜ
            if (checkContents.Count(x => x.isAdmin == false) == 2)
            {
                TempData["ContentStatus"] = "ContentSpam";
                return(Redirect($"~/Petition/Detail/{petitionDetailDto.Petition.PetitionID}"));
            }



            bool result = _contentService.AddContent(petitionDetailDto);



            if (result)
            {
                TempData["ContentStatus"] = "ContentAdded";
                return(Redirect($"~/Petition/Detail/{petitionDetailDto.Petition.PetitionID}"));
            }
            else
            {
                TempData["ContentStatus"] = "ContentNotAdded";
                return(Redirect($"~/Petition/Detail/{petitionDetailDto.Petition.PetitionID}"));
            }
        }
Beispiel #2
0
        public string Post([FromBody] JObject value)
        {
            var dict = value.ToObject <Dictionary <string, SerContent> >();

            if (dict != null)
            {
                return(JsonConvert.SerializeObject(new StatusResponse
                {
                    Status = true,
                    NewItemId = _service.AddContent(dict["content"])
                }));
            }
            return(StatusResponse.FalseResponse());
        }
Beispiel #3
0
        public IActionResult AddContent(ListPetitionDetailDto petitionDetailDto)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Detail", "Petition"));
            }


            bool result = _contentService.AddContent(petitionDetailDto);


            if (result)
            {
                TempData["ContentStatus"] = "ContentAdded";
                return(Redirect($"/Admin/Petition/Detail/{petitionDetailDto.Petition.PetitionID}"));
            }
            else
            {
                TempData["ContentStatus"] = "ContentNotAdded";
                return(Redirect($"/Admin/Petition/Detail/{petitionDetailDto.Petition.PetitionID}"));
            }
        }
        public Comment AddComment(string url, string content, long creatorId, long?parentId)
        {
            var creator = _userService.GetUserById(creatorId);

            if (creator != null)
            {
                //Get all the info needed for the insertion
                var subDirectory  = _subDirectoryService.FindOrInsertSite(url);
                var contentObj    = _contentService.AddContent(subDirectory.Id, ContentTypeMap.Comment);
                var parentComment = (Comment)null;
                if (parentId.HasValue)
                {
                    parentComment = GetCommentById(parentId.Value);
                }
                //Add the comment
                var comment = new Comment()
                {
                    Upvotes           = 0,
                    Sitename          = subDirectory.Site?.Name,
                    Content           = content,
                    CreatedAt         = DateTime.Now,
                    ContentId         = contentObj.Id,
                    CreatorId         = creatorId,
                    CreatedByAdmin    = false,
                    ModifiedAt        = DateTime.Now,
                    ParentId          = parentComment != null ? parentId : null,
                    ProfilePictureUrl = creator.ProfilePictureUrl,
                    Pings             = 0
                };
                _commentRepository.Add(comment);
                var saved = Convert.ToBoolean(_commentRepository.Save());
                if (saved)
                {
                    return(comment);
                }
            }
            return(null);
        }
        public IActionResult Create(AddContentViewModel addContent)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (_conService.AddContent(addContent, _env))
                    {
                        return(RedirectToAction(nameof(Index)));
                    }

                    return(View("Error", new ErrorViewModel {
                        RequestId = "Unable to perform your request"
                    }));
                }
                catch
                {
                    return(View("Error", new ErrorViewModel {
                        RequestId = "Unable to perform your request"
                    }));
                }
            }
            return(View());
        }
        public bool AddPetition(CreatePetitionDto createPetitionDto)
        {
            try
            {
                Petition newPetition = new Petition()
                {
                    Summary = createPetitionDto.Summary,
                    Statu   = (int)Statu.Gönderildi,
                    //MEVCUT LOGİN KULLANICI ÜZERİNE OLUŞTUR
                    UserId = createPetitionDto.UserID,
                    Date   = DateTime.Now
                };


                _petitionDal.Add(newPetition);


                Content newContent = new Content()
                {
                    PetitionID  = newPetition.PetitionID,
                    Description = createPetitionDto.FirstComment,
                    Date        = DateTime.Now,
                    UserId      = createPetitionDto.UserID,
                };

                bool result = _contentService.AddContent(newContent);
                MailHelper.SendPetitionCreated(newPetition, createPetitionDto.Email);

                return(result);
            }

            catch
            {
                return(false);
            }
        }
Beispiel #7
0
 public ResponseResult <bool> AddContent([FromBody] ContentDto contentDto)
 {
     return(_service.AddContent(contentDto));
 }