Beispiel #1
0
 private Offer(
         int offerId,
         int? advertId,
         int? agencyId,
         int collectiveCategoryId,
         string name,
         double priceReal,
         double priceSave,
         double price,
         int currencyId,
         OfferStatusType status,
         string categoryName,
         double? discount,
         DateTime dateStart,
         DateTime dateEnd,
         DateTime dateCouponStart,
         DateTime dateCouponEnd,
         int? numberOfPersons,
         int? numberOfCouponsPerUser,
         int minBoughtCount,
         int maxBoughtCount,
         int boughtCount,
         int clickCount,
         string offerType,
         double? longitude,
         double? latitude,
         int priority,
         bool active
         )
 {
     this.OfferId = offerId;
     this.AdvertId = advertId;
     this.AgencyId = agencyId;
     this.CollectiveCategoryId = collectiveCategoryId;
     this.OfferName = name;
     this.PriceReal = priceReal;
     this.PriceSave = priceSave;
     this.Price = price;
     this.CurrencyId = currencyId;
     this.OfferStatus = status;
     this.CategoryName = categoryName;
     this.Discount = discount;
     this.DateStart = dateStart;
     this.DateEnd = dateEnd;
     this.DateCouponStart = dateCouponStart;
     this.DateCouponEnd = dateCouponEnd;
     this.NumberOfPersons = numberOfPersons;
     this.NumberOfCouponsPerUser = numberOfCouponsPerUser;
     this.MinBoughtCount = minBoughtCount;
     this.MaxBoughtCount = maxBoughtCount;
     this.BoughtCount = boughtCount;
     this.ClickCount = clickCount;
     this.OfferType = offerType;
     this.Longitude = longitude;
     this.Latitude = latitude;
     this.Priority = priority;
     this.Active = active;
 }
Beispiel #2
0
        public static Offer UpdateOffer(
                            int id,
                            int? advertId,
                            int? agencyId,
                            int collectiveCategoryId,
                            string name,
                            double priceReal,
                            double priceSave,
                            double price,
                            int currencyId,
                            OfferStatusType status,
                            double? discount,
                            DateTime dateStart,
                            DateTime dateEnd,
                            DateTime dateCouponStart,
                            DateTime dateCouponEnd,
                            int? numberOfPersons,
                            int? numberOfCouponsPerUser,
                            int minBoughtCount,
                            int maxBoughtCount,
                            string offerType,
                            double? longitude,
                            double? latitude,
                            int priority,
                            bool active,
                            List<int> lstPlacesIds
                            )
        {
            // da budem siguran da je vrijeme 0:00:00
            dateStart = new DateTime(dateStart.Year, dateStart.Month, dateStart.Day);
            dateEnd = new DateTime(dateEnd.Year, dateEnd.Month, dateEnd.Day);
            dateCouponStart = new DateTime(dateCouponStart.Year, dateCouponStart.Month, dateCouponStart.Day);
            dateCouponEnd = new DateTime(dateCouponEnd.Year, dateCouponEnd.Month, dateCouponEnd.Day);

            using (SqlConnection con = new SqlConnection(PutovalicaUtil.GetConnectionString()))
            {
                using (SqlCommand cmd = new SqlCommand()
                {
                    Connection = con,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "Collective_UpdateOffer"
                })
                {
                    cmd.Parameters.Add(new SqlParameter("@Id", SqlDbType.Int, 4) { Value = id });

                    if (advertId.HasValue)
                        cmd.Parameters.Add(new SqlParameter("@AdvertId", SqlDbType.Int, 4) { Value = advertId.Value });
                    if (agencyId.HasValue)
                        cmd.Parameters.Add(new SqlParameter("@AgencyId", SqlDbType.Int, 4) { Value = agencyId.Value });
                    cmd.Parameters.Add(new SqlParameter("@CollectiveCategoryId", SqlDbType.Int, 4) { Value = collectiveCategoryId });
                    cmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.NVarChar, 250) { Value = name });
                    cmd.Parameters.Add(new SqlParameter("@PriceReal", SqlDbType.Decimal, 8) { Precision = 15, Scale = 2, Value = priceReal });
                    cmd.Parameters.Add(new SqlParameter("@PriceSave", SqlDbType.Decimal, 8) { Precision = 15, Scale = 2, Value = priceSave });
                    cmd.Parameters.Add(new SqlParameter("@Price", SqlDbType.Decimal, 8) { Precision = 15, Scale = 2, Value = price });
                    cmd.Parameters.Add(new SqlParameter("@CurrencyId", SqlDbType.Int, 4) { Value = currencyId });
                    cmd.Parameters.Add(new SqlParameter("@Status", SqlDbType.Char, 1) { Value = (char)status });
                    SqlParameter parCategoryName = new SqlParameter("@CategoryName", SqlDbType.NVarChar, 250) { Direction = ParameterDirection.Output };
                    cmd.Parameters.Add(parCategoryName);
                    if (discount.HasValue)
                        cmd.Parameters.Add(new SqlParameter("@Discount", SqlDbType.Decimal, 8) { Value = discount.Value });
                    cmd.Parameters.Add(new SqlParameter("@DateStart", SqlDbType.SmallDateTime, 4) { Value = dateStart });
                    cmd.Parameters.Add(new SqlParameter("@DateEnd", SqlDbType.SmallDateTime, 4) { Value = dateEnd });
                    cmd.Parameters.Add(new SqlParameter("@DateCouponStart", SqlDbType.SmallDateTime, 4) { Value = dateCouponStart });
                    cmd.Parameters.Add(new SqlParameter("@DateCouponEnd", SqlDbType.SmallDateTime, 4) { Value = dateCouponEnd });
                    if (numberOfPersons.HasValue)
                        cmd.Parameters.Add(new SqlParameter("@NumberOfPersons", SqlDbType.Int, 4) { Value = numberOfPersons.Value });
                    if (numberOfCouponsPerUser.HasValue)
                        cmd.Parameters.Add(new SqlParameter("@NumberOfCouponsPerUser", SqlDbType.Int, 4) { Value = numberOfCouponsPerUser.Value });
                    cmd.Parameters.Add(new SqlParameter("@MinBoughtCount", SqlDbType.Int, 4) { Value = minBoughtCount });
                    cmd.Parameters.Add(new SqlParameter("@MaxBoughtCount", SqlDbType.Int, 4) { Value = maxBoughtCount });
                    SqlParameter parBoughtCount = new SqlParameter("@BoughtCount", SqlDbType.Int, 4) { Direction = ParameterDirection.Output };
                    cmd.Parameters.Add(parBoughtCount);
                    SqlParameter parClickCount = new SqlParameter("@ClickCount", SqlDbType.Int, 4) { Direction = ParameterDirection.Output };
                    cmd.Parameters.Add(parClickCount);
                    if (!String.IsNullOrEmpty(offerType))
                        cmd.Parameters.Add(new SqlParameter("@OfferType", SqlDbType.NVarChar, 250) { Value = offerType });
                    if (longitude.HasValue)
                        cmd.Parameters.Add(new SqlParameter("@Longitude", SqlDbType.Decimal, 8) { Precision = 10, Scale = 6, Value = longitude.Value });
                    if (latitude.HasValue)
                        cmd.Parameters.Add(new SqlParameter("@Latitude", SqlDbType.Decimal, 8) { Precision = 10, Scale = 6, Value = latitude.Value });
                    cmd.Parameters.Add(new SqlParameter("@Priority", SqlDbType.Int, 4) { Value = priority });
                    cmd.Parameters.Add(new SqlParameter("@Active", SqlDbType.Bit, 1) { Value = active });

                    XDocument xdocPlaces = new XDocument(new XElement("root"));

                    foreach (int plId in lstPlacesIds)
                    {
                        xdocPlaces.Root.Add(new XElement("place",
                            new XAttribute("id", plId.ToString())));
                    }

                    cmd.Parameters.Add(new SqlParameter("@Places", SqlDbType.Xml) { Value = xdocPlaces.ToString() });

                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();

                    return new Offer(
                            id,
                            advertId,
                            agencyId,
                            collectiveCategoryId,
                            name,
                            priceReal,
                            priceSave,
                            price,
                            currencyId,
                            status,
                            parCategoryName.Value.ToString(),
                            discount,
                            dateStart,
                            dateEnd,
                            dateCouponStart,
                            dateCouponEnd,
                            numberOfPersons,
                            numberOfCouponsPerUser,
                            minBoughtCount,
                            maxBoughtCount,
                            Convert.ToInt32(parBoughtCount.Value),
                            Convert.ToInt32(parClickCount.Value),
                            offerType,
                            longitude,
                            latitude,
                            priority,
                            active
                        ) { IsClientDataSet = false };
                }
            }
        }
Beispiel #3
0
 private Offer(
         int offerId,
         int? advertId,
         int? agencyId,
         int collectiveCategoryId,
         string name,
         double? priceReal,
         double? priceSave,
         double? price,
         int currencyId,
         OfferStatusType status,
         string categoryName,
         double? discount,
         DateTime? dateStart,
         DateTime? dateEnd,
         DateTime? dateCouponStart,
         DateTime? dateCouponEnd,
         int? numberOfPersons,
         int? numberOfCouponsPerUser,
         int minBoughtCount,
         int maxBoughtCount,
         int boughtCount,
         int clickCount,
         string offerType,
         double? longitude,
         double? latitude,
         int priority,
         bool active,
         string firstImgSrc,
         int? langId,
         string offerTitle,
         string contentShort,
         string contentText,
         string reservationText,
         string currencySymbol
         )
 {
     this.OfferId = offerId;
     this.AdvertId = advertId;
     this.AgencyId = agencyId;
     this.CollectiveCategoryId = collectiveCategoryId;
     this.OfferName = name;
     this.PriceReal = priceReal;
     this.PriceSave = priceSave;
     this.Price = price;
     this.CurrencyId = currencyId;
     this.OfferStatus = status;
     this.CategoryName = categoryName;
     this.Discount = discount;
     this.DateStart = dateStart;
     this.DateEnd = dateEnd;
     this.DateCouponStart = dateCouponStart;
     this.DateCouponEnd = dateCouponEnd;
     this.NumberOfPersons = numberOfPersons;
     this.NumberOfCouponsPerUser = numberOfCouponsPerUser;
     this.MinBoughtCount = minBoughtCount;
     this.MaxBoughtCount = maxBoughtCount;
     this.BoughtCount = boughtCount;
     this.ClickCount = clickCount;
     this.OfferType = offerType;
     this.Longitude = longitude;
     this.Latitude = latitude;
     this.Priority = priority;
     this.Active = active;
     this.FirstImgSrc = firstImgSrc;
     this.LanguageId = langId;
     this.OfferTitle = offerTitle;
     this.ContentShort = contentShort;
     this.ContentText = contentText;
     this.ReservationText = reservationText;
     this.CurrencySymbol = currencySymbol;
 }