Exemplo n.º 1
0
        //WIZARD related ADD & UPDATE
        public int WizardAdd(EventWizardAddRequest model, int userId)
        {
            int     id       = 0;
            string  procName = "[dbo].[EventWizard_Insert]";
            Product product  = null;
            Price   price    = null;

            if (model.Price > 0)
            {
                string productName = "ValoreEvents_" + model.Name;
                product = CreateStripeProduct(productName);
                price   = CreateStripeProductPrice(product.Id, model.Price * 100);
            }

            _data.ExecuteNonQuery(procName, delegate(SqlParameterCollection col)
            {
                EventWizardParamMapper(model, col, userId, product, price);
                SqlParameter idOut = new SqlParameter("@OutputId", SqlDbType.Int);
                idOut.Direction    = ParameterDirection.Output;
                col.Add(idOut);
            }, delegate(SqlParameterCollection returnCollection)
            {
                object oId = returnCollection["@OutputId"].Value;
                int.TryParse(oId.ToString(), out id);
            });

            return(id);
        }
Exemplo n.º 2
0
 private static void EventWizardParamMapper(EventWizardAddRequest model, SqlParameterCollection col, int userId, Product product, Price price)
 {
     //Event
     col.AddWithValue("@EventTypeId", model.EventTypeId);
     col.AddWithValue("@Name", model.Name);
     col.AddWithValue("@Summary", model.Summary);
     col.AddWithValue("@ShortDescription", model.ShortDescription);
     col.AddWithValue("@EventStatusId", model.EventStatusId);
     col.AddWithValue("@ImageUrl", model.ImageUrl);
     col.AddWithValue("@ExternalSiteUrl", model.ExternalSiteUrl);
     col.AddWithValue("@IsFree", model.IsFree);
     col.AddWithValue("@DateStart", model.DateStart);
     col.AddWithValue("@DateEnd", model.DateEnd);
     col.AddWithValue("@Price", model.Price);
     col.AddWithValue("@Capacity", model.Capacity);
     //Location
     col.AddWithValue("@LocationTypeId", model.LocationTypeId);
     col.AddWithValue("@LocationLineOne", model.LocationLineOne);
     col.AddWithValue("@LocationLineTwo", model.LocationLineTwo);
     col.AddWithValue("@LocationCity", model.LocationCity);
     col.AddWithValue("@LocationZip", model.LocationZip);
     col.AddWithValue("@LocationStateId", model.LocationStateId);
     col.AddWithValue("@LocationLatitude", model.LocationLatitude);
     col.AddWithValue("@LocationLongitude", model.LocationLongitude);
     //Venue
     col.AddWithValue("@VenueId", model.VenueId);
     col.AddWithValue("@VenueName", model.VenueName);
     col.AddWithValue("@VenueDescription", model.VenueDescription);
     col.AddWithValue("@VenueLocationId", model.VenueLocationId);
     col.AddWithValue("@VenueUrl", model.VenueUrl);
     //User
     col.AddWithValue("@UserId", userId);
     //PaymentInfo
     if (model.Price > 0)
     {
         col.AddWithValue("@StripeProductId", product.Id);
         col.AddWithValue("@StripePriceId", price.Id);
     }
     else
     {
         col.AddWithValue("@StripeProductId", null);
         col.AddWithValue("@StripePriceId", null);
     }
 }
Exemplo n.º 3
0
        public ActionResult <ItemResponse <int> > WizardAdd(EventWizardAddRequest model)
        {
            int          code     = 201;
            BaseResponse response = null;

            try
            {
                int userId = _authService.GetCurrentUserId();
                int id     = _service.WizardAdd(model, userId);
                response = new ItemResponse <int> {
                    Item = id
                };
            }
            catch (Exception ex)
            {
                code     = 500;
                response = new ErrorResponse($"Server Error {ex.Message}");
                base.Logger.LogError(ex.ToString());
            }

            return(StatusCode(code, response));
        }