WithGuid() public method

public WithGuid ( System.Guid aGuid ) : AObject
aGuid System.Guid
return AObject
Example #1
0
        protected void InitializeDelete(AObjects aObjects, string aPath)
        {
            this.RequiresAuthentication();

            Delete["/" + aPath + "/{guid:guid}", true] = async(_, ct) =>
            {
                try
                {
                    var obj = aObjects.WithGuid(Guid.Parse(_.guid));
                    if (obj != null)
                    {
                        obj.Parent.Remove(obj);
                        return CreateSuccessResponseAndUpdateApiKey(_.format);
                    }
                    return CreateErrorResponseAndUpdateApiKey(HttpStatusCode.NotFound);
                }
                catch (Exception ex)
                {
                    return CreateErrorResponseAndUpdateApiKey(ex.Message);
                }
            };
        }
Example #2
0
        protected void InitializeGet(AObjects aObjects, string aPath)
        {
            this.RequiresAuthentication();

            Get["/" + aPath + "/{guid:guid}", true] = async(_, ct) =>
            {
                try
                {
                    var obj = aObjects.WithGuid(Guid.Parse(_.guid));
                    if (obj != null)
                    {
                        return CreateSuccessResponseAndUpdateApiKey(Helper.XgObjectToNancyObject(obj));
                    }
                    return CreateErrorResponseAndUpdateApiKey(HttpStatusCode.NotFound);
                }
                catch (Exception ex)
                {
                    return CreateErrorResponseAndUpdateApiKey(ex.Message);
                }
            };
        }