예제 #1
0
        public ItemTypes EditItemType(string userId, IncomingEditItemType addItemType)
        {
            var canEdit = this.CanUserEditItemTypes(userId, addItemType.ItemTypeId);

            if (canEdit == false)
            {
                throw new UnauthorizedAccessException();
            }

            var itemType = this.dbContext.ItemTypes.FirstOrDefault(x => x.Id == addItemType.ItemTypeId);

            if (itemType == null)
            {
                throw new UnauthorizedAccessException();
            }

            itemType.Name = addItemType.Name;

            return(itemType);
        }
예제 #2
0
        public HttpResponseMessage EditVenueItemType(IncomingEditItemType editItemType)
        {
            return(ErrorFactory.Handle(() =>
            {
                var userId = User?.Identity?.GetUserId();

                if (string.IsNullOrWhiteSpace(userId))
                {
                    throw new UnauthorizedAccessException();
                }

                using (var unitOfWork = new UnitOfWork())
                {
                    var editVenueItemType = unitOfWork.ItemTypes.EditItemType(userId, editItemType);

                    var outgoingItemType = OutgoingVenueItemType.Parse(editVenueItemType);

                    unitOfWork.Complete();

                    return JsonFactory.CreateJsonMessage(outgoingItemType, HttpStatusCode.OK, this.Request);
                }
            }, this.Request));
        }