public void Create(RequestModel requestModel)
        {
            _repos.Create(requestModel);
            IEnumerable <RequestModel> requestList = _cache.Get <IEnumerable <RequestModel> >("requestList");

            if (requestList != null)
            {
                _cache.Delete("requestList");
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Create([FromBody] RequestItemRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                var userIdClaim = ((ClaimsIdentity)User.Identity).FindFirst(ClaimTypes.NameIdentifier);
                var userId      = int.Parse(userIdClaim.Value);

                var itemId = await _requestsRepository.Create(request, userId);

                return(CreatedAtAction(nameof(GetById), new { id = itemId }, itemId));
            }
            catch (DuplicateOfficeException) // TODO
            {
                return(StatusCode(StatusCodes.Status409Conflict, new { Message = "An office with those details already exists." }));
            }
        }