Exemplo n.º 1
0
 public IActionResult EditStatus([FromBody] VMSuggestionEditStatus request)
 {
     if (request.UserId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
     {
         return(Unauthorized());
     }
     if (!_repository.AdminorModerator(request.UserId))
     {
         return(Unauthorized());
     }
     else
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         VMMessage msj = _repository.UpdateStatus(request);
         if (msj.IsSuccessful())
         {
             return(Ok("Edited Successfully."));
         }
         else
         {
             return(BadRequest(msj.Text));
         }
     }
 }
Exemplo n.º 2
0
        public IActionResult Edit([FromBody] VMSuggestion request)
        {
            if (request.IdAuthor != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (_repository.isFullfilled(request.Id))
            {
                return(BadRequest());
            }
            request.UpdatedDate = DateTime.Now;
            VMMessage msj = _repository.Update(request);

            if (msj.IsSuccessful())
            {
                return(Ok("Edited Successfully."));
            }
            else
            {
                return(BadRequest(msj.Text));
            }
        }
Exemplo n.º 3
0
        public void Create()
        {
            IRSuggestion r  = new REFSuggestion(new DataContext(TestBaseEF.GetOptionBuilder().Options));
            VMSuggestion vm = new VMSuggestion()
            {
                Title        = "My Test",
                Description  = "My Description",
                CreatedDate  = DateTime.Now,
                UpdatedDate  = DateTime.Now,
                QuantityVote = 0,
                Author       = new VMUserSimple(1)
            };
            VMMessage msj = r.Insert(vm);

            Assert.IsTrue(msj.IsSuccessful());
        }
Exemplo n.º 4
0
        public IActionResult Create([FromBody] VMSuggestionAdd request)
        {
            //var aud = User.Claims.First(x => x.Value == request.Tenant);
            //if (aud == null)
            //    return Unauthorized();
            int currentstatus;

            if (request.IdAuthor != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            if (_repository.Moderation(request.IdAuthor) && !_repository.AdminorModerator(request.IdAuthor))
            {
                currentstatus = 1;
            }
            else
            {
                currentstatus = 2;
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            VMSuggestion vm = new VMSuggestion()
            {
                Title        = request.Title.ToUpper(),
                Description  = request.Description,
                CreatedDate  = DateTime.Now,
                UpdatedDate  = DateTime.Now,
                QuantityVote = 0,
                Author       = new VMUserSimple(request.IdAuthor),
                StatusId     = currentstatus
            };
            VMMessage msj = _repository.Insert(vm);

            if (msj.IsSuccessful())
            {
                return(Ok(vm));
            }
            else
            {
                return(BadRequest(msj.Text));
            }
        }
Exemplo n.º 5
0
        public IActionResult Remove(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            VMMessage msj = _repository.Delete(id);

            if (msj.IsSuccessful())
            {
                return(Ok("Deleted Successfully."));
            }
            else
            {
                return(BadRequest(msj.Text));
            }
        }
Exemplo n.º 6
0
        public IActionResult Create([FromBody] VMReplyAdd request)
        {
            if (request.IdAuthor != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            if (!_repository.AdminorModerator(request.IdAuthor))
            {
                return(Unauthorized());
            }
            if (_repository.isFullfilled(request.IdSuggestion))
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            VMReply vm = new VMReply()
            {
                Description  = request.Description,
                CreatedDate  = DateTime.Now,
                UpdatedDate  = DateTime.Now,
                Author       = new VMUserSimple(request.IdAuthor),
                IdSuggestion = request.IdSuggestion
            };
            VMMessage msj = _repository.Insert(vm);

            if (msj.IsSuccessful())
            {
                return(Ok(vm));
            }
            else
            {
                return(BadRequest(msj.Text));
            }
        }