Exemplo n.º 1
0
        public virtual IHttpActionResult Get(string id)
        {
            try
            {
                Durados.Web.Mvc.View view = (Durados.Web.Mvc.View)Maps.Instance.DuradosMap.Database.Views[viewName];
                if (view == null)
                {
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, string.Format(Messages.ViewNameNotFound, viewName))));
                }

                if (string.IsNullOrEmpty(id))
                {
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, Messages.IdIsMissing)));
                }

                if (!view.IsAllow())
                {
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.Forbidden, Messages.ViewIsUnauthorized)));
                }

                var item = RestHelper.Get(view, id, false, view_BeforeSelect, view_AfterSelect, false, false, true);

                if (item == null)
                {
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, string.Format(Messages.ItemWithIdNotFound, id, viewName))));
                }

                return(Ok(item));
            }
            catch (Exception exception)
            {
                throw new BackAndApiUnexpectedResponseException(exception, this);
            }
        }
Exemplo n.º 2
0
 protected virtual bool IsAllow(Durados.Web.Mvc.View view)
 {
     return(view.IsAllow());
 }