示例#1
0
        public async Task <IRequestType> Update(IRequestType entity)
        {
            TRequestType tEntity = entity as TRequestType;

            var errors = await this.ValidateEntityToCheckExistsAtUpdate(tEntity);

            if (errors.Count() > 0)
            {
                await this.ThrowEntityException(errors);
            }

            try
            {
                this.StartTransaction();
                await base.Update(tEntity, x => new
                {
                    x.Name,
                    x.Description,
                    x.Enabled,
                    x.ModifiedBy,
                    x.ModifiedDate
                });

                this.CommitTransaction();
                return(tEntity);
            }
            catch (PostgresException ex)
            {
                throw new EntityUpdateException(ex);
            }
            catch
            {
                throw;
            }
        }
示例#2
0
        public async Task <IRequestType> AddNew(IRequestType entity)
        {
            TRequestType tEntity = entity as TRequestType;

            var errors = await this.ValidateEntityToCheckExists(tEntity);

            if (errors.Count() > 0)
            {
                await this.ThrowEntityException(errors);
            }

            try
            {
                this.StartTransaction();
                var savedEntity = await base.AddNew(entity as TRequestType);

                this.CommitTransaction();

                return(savedEntity);
            }
            catch (PostgresException ex)
            {
                throw new EntityUpdateException(ex);
            }
            catch
            {
                throw;
            }
        }
示例#3
0
        internal static IRequestType GetArgonautRequestType(this HttpContext context, string apiPath, bool includeAuthGeneration)
        {
            if (context.Request.Path.ToString().ToLower().Contains(apiPath.ToLower()))
            {
                return(new BearerRequestType());
            }

            if (!context.Request.HasFormContentType)
            {
                return(new UnknownRequestType());
            }

            if (!includeAuthGeneration)
            {
                return(new UnknownRequestType());
            }

            IRequestType requestType = null;

            if (context.Request.Form.Keys.Contains("grant_type"))
            {
                var pascalGrantType =
                    (from x in context.Request.Form["grant_type"].ToString().Split('_') let first_char = char.ToUpper(x[0])
                                                                                                         let rest_chars = new string(x.Skip(1).Select(c => char.ToLower(c)).ToArray())
                                                                                                                          select first_char + rest_chars).Aggregate((x, y) => x + "" + y);

                requestType = (from at in ArgonautRequestTypes.GetTypes() let t = at.GetType()
                                                                                  where t.Name.Substring(0, t.Name.Replace("RequestType", "").Length).Equals(pascalGrantType) select at).FirstOrDefault();
            }

            if (requestType != null)
            {
                return(requestType);
            }
            else
            {
                return(new UnknownRequestType());
            }
        }
示例#4
0
 public void Send(IRequestType message) => SendInternal(message);
示例#5
0
        public RequestController(IRequest request, IRequestType requestType, ICustomer customer)
        {
            _request = request;

            _customer = customer;
        }