Exemplo n.º 1
0
        public async Task <IActionResult> Delete(int id)
        {
            var hasPermission = await _authorizationService.AuthorizeAsync(User, "USER", Operations.Delete);

            if (hasPermission.Succeeded == false)
            {
                return(new BadRequestObjectResult(CommonConstants.Forbidden));
            }
            _subcribleService.Delete(id);
            _subcribleService.SaveChanges();
            return(new OkObjectResult(id));
        }
Exemplo n.º 2
0
 public IActionResult AddSubcrible(string email)
 {
     if (email != null && email != "")
     {
         const string pattern = @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|" + @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)" + @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$";
         var          regex   = new Regex(pattern, RegexOptions.IgnoreCase);
         bool         isEmail = regex.IsMatch(email);
         if (isEmail)
         {
             if (_subcribleService.CheckExit(email) == false)
             {
                 _subcribleService.Add(email);
                 _subcribleService.SaveChanges();
                 return(new OkObjectResult(new { status = true }));
             }
             else
             {
                 return(new OkObjectResult(new { status = false }));
             }
         }
         return(new OkObjectResult(new { status = false }));
     }
     return(new OkObjectResult(new { status = false }));
 }