Exemplo n.º 1
0
        public async Task <IActionResult> AddPage([FromBody] AdvertistmentPageViewModel advertistmentPageVm)
        {
            var hasPermission = await _authorizationService.AuthorizeAsync(User, "ADVERTISMENT", Operations.Create);

            if (hasPermission.Succeeded == false)
            {
                return(new BadRequestObjectResult(CommonConstants.Forbidden));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    _advertistmentService.AddPageName(advertistmentPageVm);
                    _advertistmentService.SaveChanges();
                    return(new OkObjectResult(advertistmentPageVm));
                }
                catch (Exception ex)
                {
                    return(new BadRequestObjectResult(ex.Message));
                }
            }
            return(new BadRequestObjectResult(ModelState));
        }
Exemplo n.º 2
0
 public void AddPageName(AdvertistmentPageViewModel advertistmentPageVm)
 {
     _advertistmentPageRepository.Add(_mapper.Map <AdvertistmentPage>(advertistmentPageVm));
 }
Exemplo n.º 3
0
 public AdvertistmentPage(AdvertistmentPageViewModel advertistmentPageVm)
 {
     Id   = advertistmentPageVm.Id;
     Name = advertistmentPageVm.Name;
 }