Esempio n. 1
0
        protected internal virtual void ProcessRequest(HttpContextBase context)
        {
            var resourceId = ResourceId ?? context.Request["id"];

            if (resourceId.IsNullOrWhiteSpace())
            {
                context.SetStatusCode(HttpStatusCode.BadRequest, "Missing resource id");
                return;
            }

            var resources = _repository.GetByKey(resourceId) ?? Enumerable.Empty<ClientResource>();

            if (resources.Any() == false)
            {
                context.SetStatusCode(HttpStatusCode.NotFound);
                return;
            }

            var content = _loader.Load(resources);

            if (context.HasBeenModifiedSince(content.LastModified) == false)
            {
                context.SetStatusCode(HttpStatusCode.NotModified);
                return;
            }

            Render(context, content);
        }