Ejemplo n.º 1
0
        public async Task <IActionResult> Add([FromBody] ServiceDTO dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var userId = Utility.GetCurrentUserId(User);

            var newService = _mapper.Map <Models.Services>(dto);

            newService = await _service.Add(newService, userId);

            return(Ok(newService.Id));
        }
Ejemplo n.º 2
0
        public ActionResult Create(service ser)
        {
            string role = null;

            ViewData["Role"] = "";
            IEnumerable <string> roles = new List <string>();

            roles = ((ClaimsIdentity)User.Identity).Claims
                    .Where(c => c.Type == ClaimTypes.Role)
                    .Select(c => c.Value);
            foreach (var x in roles)
            {
                role = x;
            }

            if (role != null)
            {
                ViewData["Role"] = role;
            }
            ser.user_idUser = User.Identity.GetUserId();
            se.Add(ser);
            se.Commit();
            return(RedirectToAction("Index"));
        }