Beispiel #1
0
        public static async Task <long> AddAsync(string tenant, GiftCardFund model)
        {
            const string sql =
                @"SELECT * FROM sales.add_gift_card_fund(@0::integer, @1::integer, @2::bigint, sales.get_gift_card_id_by_gift_card_number(@3), @4::date, @5::date, @6::integer, @7::public.money_strict, @8::integer, @9, @10);";

            return
                (await
                 Factory.ScalarAsync <long>(tenant, sql, model.UserId, model.OfficeId, model.LoginId, model.GiftCardNumber, model.ValueDate, model.BookDate, model.AccountId, model.Amount,
                                            model.CostCenterId, model.ReferenceNumber, model.StatementReference).ConfigureAwait(false));
        }
Beispiel #2
0
        public static async Task <long> AddAsync(string tenant, GiftCardFund model)
        {
            string sql = @"SELECT * FROM sales.add_gift_card_fund(@0::integer, @1::integer, @2::bigint, sales.get_gift_card_id_by_gift_card_number(@3), @4::date, @5::date, @6::integer, @7::public.money_strict, @8::integer, @9, @10);";

            if (DbProvider.GetDbType(DbProvider.GetProviderName(tenant)) == DatabaseType.SqlServer)
            {
                sql = FrapidDbServer.GetProcedureCommand(tenant, "sales.add_gift_card_fund", new[] { "@0", "@1", "@2", "@3", "@4", "@5", "@6", "@7", "@8", "@9", "@10" });
            }

            return(await Factory.ScalarAsync <long>(tenant, sql, model.UserId, model.OfficeId, model.LoginId, model.GiftCardNumber, model.ValueDate, model.BookDate, model.AccountId, model.Amount,
                                                    model.CostCenterId, model.ReferenceNumber, model.StatementReference).ConfigureAwait(false));
        }
Beispiel #3
0
        public async Task <ActionResult> AddFundEntryAsync(GiftCardFund model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.InvalidModelState(this.ModelState));
            }

            try
            {
                var meta = await AppUsers.GetCurrentAsync().ConfigureAwait(true);

                model.OfficeId = meta.OfficeId;
                model.UserId   = meta.UserId;
                model.LoginId  = meta.LoginId;

                long id = await GiftCardFunds.AddAsync(this.Tenant, model).ConfigureAwait(true);

                return(this.Ok(id));
            }
            catch (Exception ex)
            {
                return(this.Failed(ex.Message, HttpStatusCode.InternalServerError));
            }
        }