Beispiel #1
0
        public OfferDto AddOffer(OfferDto offerDto)
        {
            offerDto.ClientID = GetClientID(offerDto);

            Offer offer = Mapper.Map <OfferDto, Offer>(offerDto);

            offer = _offerRepository.Add(offer);

            //TODO: stored procedure that will take xml and process offer
            foreach (OfferNoteDto noteDto in offerDto.OfferNotes)
            {
                noteDto.OfferID = offer.ID;

                OfferNote note = Mapper.Map <OfferNoteDto, OfferNote>(noteDto);
                _offerNoteRepository.Add(note);
            }

            foreach (OfferSectionDto sectionDto in offerDto.OfferSections)
            {
                sectionDto.OfferID = offer.ID;

                OfferSection section = Mapper.Map <OfferSectionDto, OfferSection>(sectionDto);
                section = _offerSectionRepository.Add(section);

                foreach (OfferItemDto itemDto in sectionDto.OfferItems)
                {
                    itemDto.OfferSectionID = section.ID;

                    OfferItem item = Mapper.Map <OfferItemDto, OfferItem>(itemDto);
                    _offerItemRepository.Add(item);
                }
            }

            return(Mapper.Map <Offer, OfferDto>(offer));
        }
Beispiel #2
0
        public void UpdateOffer(OfferDto offerDto)
        {
            offerDto.ClientID = GetClientID(offerDto);

            Offer offer = _offerRepository.Find(offerDto.ID);

            _offerRepository.Update(Mapper.Map(offerDto, offer));

            //TODO: stored procedure that will take xml and process offer
            foreach (OfferNoteDto noteDto in offerDto.OfferNotes)
            {
                OfferNote note = _offerNoteRepository.Find(noteDto.ID.Value);
                _offerNoteRepository.Update(Mapper.Map(noteDto, note));
            }

            foreach (OfferSectionDto sectionDto in offerDto.OfferSections)
            {
                OfferSection section = _offerSectionRepository.Find(sectionDto.ID.Value);
                _offerSectionRepository.Update(Mapper.Map(sectionDto, section));

                foreach (OfferItemDto itemDto in sectionDto.OfferItems)
                {
                    OfferItem item = _offerItemRepository.Find(itemDto.ID.Value);
                    _offerItemRepository.Add(Mapper.Map(itemDto, item));
                }
            }
        }
        public void InsertOfferItem(SaveDataModel inputObject)
        {
            // Get sysdate
            var currentDate = DateTime.Now;

            // Get max
            var max = GetMaxOffer(inputObject.OfferCd);

            // Set item
            var entity = new OfferItem();

            entity.OfferCd       = inputObject.OfferCd;
            entity.DetailNo      = max + 1;
            entity.OfferItemCd   = inputObject.OfferItemCd;
            entity.OfferItemQtty = inputObject.OfferItemQtty;
            entity.SortKey       = decimal.Zero;
            entity.CreateUser    = PageHelper.UserName;
            entity.CreateDate    = currentDate;
            entity.UpdateUser    = PageHelper.UserName;
            entity.UpdateDate    = currentDate;
            entity.DeleteFlag    = inputObject.DeleteFlag;

            EntityManager.OfferItems.InsertOnSubmit(entity);

            // Submit
            EntityManager.SubmitChanges();
        }
Beispiel #4
0
        public OffersPageViewModel GetOffersPageViewModel(int currentUmbracoPageId)
        {
            var _model = new OffersPageViewModel();

            //Aktualna strona, na której się znajdujemy
            var _currentPage = _umbracoHelper.TypedContent(currentUmbracoPageId);
            var currPage     = new OffersPromotions(_currentPage);
            //Aktualna lokalizacja, na której się znajdujemy
            var _localizationNode = _currentPage.AncestorOrSelf(DocumentTypeEnum.location.ToString());

            _model.OffersPageName = _currentPage.Name;
            _model.OffersBox      = new List <OfferItem>();
            var _currentNodeChildren = _currentPage.Children.Where("Visible");

            foreach (var item in _currentPage.Children.Where("Visible"))
            {
                var typeItem   = new OffersPromotions(item);
                var _offerItem = new OfferItem()
                {
                    offersPageName = item.Name, Link = item.Url, pageCategory = Enum.Parse(typeof(OffersPageTypeEnum), JsonConvert.DeserializeObject <IEnumerable <NuPickersSqlDropDownPicker> >(typeItem.PageType.SavedValue.ToString()).FirstOrDefault().Key.ToString()).ToString()
                };
                _model.OffersBox.Add(_offerItem);
            }
            return(_model);
        }
Beispiel #5
0
        public static IEnumerable <object[]> SuccessfulOfferResponses()
        {
            OfferItem[] offers = GenerateOffers(3).ToArray();
            OfferItem   o1     = offers[0];
            OfferItem   o2     = offers[1];
            OfferItem   o3     = offers[2];

            yield return(new object[] { GenerateOffer(o1, o2, o3), GenerateExpectedResult((o1, 1), (o2, 1), (o3, 1)) });
Beispiel #6
0
        public void BuildFromOfferItem(OfferItem oi)
        {
            Policy pi = new Policy();

            pi.Client             = oi.Offer.Client;
            pi.InsuranceCompanyID = oi.InsuranceCompanyID;
            // pi.InsuranceSubTypeID = oi.InsuranceSubTypeID;
            pi.Client1 = oi.Offer.Client1;
            _policy    = pi;
        }
Beispiel #7
0
 public PolicyInfo(int OfferItemID)
 {
     if (OfferItemID != 0)
     {
         OfferItem oi = OfferItem.Get(OfferItemID);
         _offerItem = oi;
         BuildFromOfferItem(oi);
     }
     else
     {
         _offerItem = null;
         // PolicyInfo();
     }
 }
        public void UpdateOfferItem(OfferItem param)
        {
            // Get sysdate
            var currentDate = DateTime.Now;

            // Set item
            var entity = GetSingleOfferItem(param.OfferCd, param.DetailNo);

            entity.OfferItemCd   = param.OfferItemCd;
            entity.OfferItemQtty = param.OfferItemQtty;
            entity.DeleteFlag    = param.DeleteFlag;
            entity.UpdateUser    = PageHelper.UserName;
            entity.UpdateDate    = currentDate;
        }
Beispiel #9
0
        async void addOffer_Clicked(object sender, EventArgs e)
        {
            string     title       = titleEntry.Text;
            string     description = descriptionEntry.Text;
            int        categoryId  = Convert.ToInt32(((Category)CategoryBinder.SelectedItem).CategoryID);
            int        quantity    = Convert.ToInt32(quantityEntry.Text);
            string     price       = priceEntry.Text;
            OfferState state       = (OfferState)StateBinder.SelectedItem;


            var offerItem = new Models.BindingModels.OfferBindingModel
            {
                Title            = title,
                Description      = description,
                CategoryID       = categoryId,
                InStockOriginaly = quantity,
                Price            = price,
                UserID           = Session.user.UserID,
                OfferState       = state
            };

            if (string.IsNullOrEmpty(titleEntry.Text) || string.IsNullOrEmpty(descriptionEntry.Text))
            {
                await DisplayAlert("Enter data", "Enter valid data", "Ok");
            }
            else
            {
                try
                {
                    OfferItem response = await AddOfferViewModel.AddOfferAsync(offerItem);

                    if (response != null)
                    {
                        output.Text = "Oferta dodana pomyślnie!";
                    }
                    else
                    {
                    }
                }
                catch (AggregateException err)
                {
                    foreach (var errInner in err.InnerExceptions)
                    {
                        Debug.WriteLine(errInner); //this will call ToString() on the inner execption and get you message, stacktrace and you could perhaps drill down further into the inner exception of it if necessary
                    }
                    ;
                }
            }
        }
Beispiel #10
0
        public void Update(OfferItem entity)
        {
            var offerItem = offerItemRepository.Find(entity.Id);

            offerItem.SerialNumber = entity.SerialNumber;
            offerItem.Quantity     = entity.Quantity;
            offerItem.OfferPrice   = entity.OfferPrice;
            offerItem.Stock        = entity.Stock;
            offerItem.ProductName  = entity.ProductName;
            offerItem.ProductId    = entity.ProductId;
            offerItem.CustomerId   = entity.CustomerId;
            offerItem.OfferId      = entity.OfferId;

            offerItemRepository.Update(offerItem);
            unitOfWork.SaveChanges();
        }
Beispiel #11
0
        public void Calculate_should_return_discount_when_today_is_24_12()
        {
            // Setup
            IEnumerable <OfferItem> availabeItems = new OfferItem[] { new OfferItem()
                                                                      {
                                                                          Id = "1", Name = "test", Price = 10, ProductType = global::Sales.Domain.ProductType.Printed
                                                                      } };

            _dateTimeProviderMock.Setup(f => f.Today).Returns(new DateTime(2020, 12, 24));

            // Act
            var result = _sut.Calculate(availabeItems);

            //
            Assert.AreEqual(10, result);
        }
Beispiel #12
0
        public OfferItemPage(OfferItem Offer)
        {
            InitializeComponent();
            this.offer     = Offer;
            BindingContext = Offer;
            var images     = new List <string>();
            var ItemImages = Offer.OfferPictures;

            foreach (OfferPicture offerPicture in ItemImages)
            {
                images.Add(offerPicture.PathToFile);
            }
            Price.Text                   = Offer.PriceInfo;
            Title.Text                   = Offer.Title;
            Description.Text             = Offer.Description;
            MainCarouselView.ItemsSource = images;
        }
Beispiel #13
0
        public JsonResult AddOffer(IList <OfferItemViewModel> offerItemViewModels, string tc)
        {
            try
            {
                var customerId = customerService.Find(c => c.IdentityNumber == tc).Id;


                var productList = new List <Product>();
                var newOffer    = new Offer();
                offerService.Insert(newOffer);

                foreach (var product in offerItemViewModels)
                {
                    var pr = productService.Find(p => p.SerialNumber == product.SerialNumber);

                    var newOfferItem = new OfferItem()
                    {
                        SerialNumber         = pr.SerialNumber,
                        ProductName          = pr.Name,
                        OfferPrice           = product.OfferPrice,
                        Quantity             = product.Quantity,
                        Stock                = pr.Stock,
                        RegisterRequiredDate = product.RegisterRequiredDate,
                        ProductId            = pr.Id,
                        CustomerId           = customerId,
                        OfferId              = newOffer.Id
                    };

                    offerItemService.Insert(newOfferItem);
                }


                return(Json("success"));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #14
0
        public ActionResult CreateFromPricing(Offer offerModel, FormCollection collection)
        {
            var offer = new Offer();

            offer.Name            = collection["Offer Name"];
            offer.Description     = collection["Offer Description"];
            offer.OfferFor        = collection["Offer For"];
            offer.OfferForAddress = collection["Offer For Address"];
            offer.PricingId       = Convert.ToInt16(collection["PricingId"]);
            db.Offers.Add(offer);

            foreach (string key in collection.Keys)
            {
                if (key.Contains("multiplier"))
                {
                    var value = collection[key];

                    var parts = key.Split('-').ToList().LastOrDefault();

                    var offerItem = new OfferItem();
                    if (value != string.Empty)
                    {
                        CultureInfo cult = new CultureInfo("de-DE");

                        offerItem.Value = double.Parse(value, cult);
                    }
                    else
                    {
                        offerItem.Value = 0;
                    }
                    offerItem.OfferId       = offer.Id;
                    offerItem.PricingUnitId = Convert.ToInt16(parts);
                    db.OfferItems.Add(offerItem);
                }
            }
            db.SaveChanges();
            return(View(offer));
        }
Beispiel #15
0
        public static async Task <OfferItem> AddOfferAsync(OfferBindingModel offer)
        {
            OfferItem offerItem = null;
            await Task.Run(async() =>
            {
                var client = new HttpClient();
                MultipartFormDataContent content = null;
                List <FileResult> fileResults    = AddOfferViewModel.uploadedFiles;

                if (fileResults != null)
                {
                    content = new MultipartFormDataContent("NkdKd9Yk");
                    content.Headers.ContentType.MediaType = "multipart/form-data";
                    foreach (FileResult fileResult in fileResults)
                    {
                        content.Add(new StreamContent(File.OpenRead(fileResult.FullPath)), fileResult.FileName, fileResult.FileName);
                    }
                }

                content.Headers.ContentType.MediaType = "multipart/form-data";
                var json = JsonConvert.SerializeObject(offer);
                HttpContent httpContent = new StringContent(json);

                httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");

                content.Add(httpContent);

                var response = await client.PostAsync(Service.URI + "api/Offers/", content);

                if (response.IsSuccessStatusCode)
                {
                    offerItem = JsonConvert.DeserializeObject <OfferItem>(response.Content.ReadAsStringAsync().Result);
                }
            });

            return(offerItem);
        }
Beispiel #16
0
        public int Insert(Repo.Models.Flights.Flight model, string origin, string destionation, string departureDate, string returnDate = null, string currency = Default.CURRENCY, int adults = Default.ADULTS)
        {
            if (model == null || String.IsNullOrEmpty(origin) || String.IsNullOrEmpty(destionation) || String.IsNullOrEmpty(departureDate))
            {
                throw new ArgumentNullException();
            }

            if (model.Data == null || model.Dictionaries == null || model.Meta == null)
            {
                throw new NullReferenceException();
            }

            if (model.Dictionaries.Currencies != null)
            {
                foreach (var item in model.Dictionaries.Currencies)
                {
                    if (unitOfWork.Currencies.FindByCode(item.Key) == null)
                    {
                        unitOfWork.Currencies.Insert(item);
                    }
                }
            }

            if (model.Dictionaries.Aircraft != null)
            {
                foreach (var item in model.Dictionaries.Aircraft)
                {
                    if (unitOfWork.Aircrafts.FindByCode(item.Key) == null)
                    {
                        unitOfWork.Aircrafts.Insert(item);
                    }
                }
            }

            if (model.Dictionaries.Carriers != null)
            {
                foreach (var item in model.Dictionaries.Carriers)
                {
                    if (unitOfWork.Carriers.FindByCode(item.Key) == null)
                    {
                        unitOfWork.Carriers.Insert(item);
                    }
                }
            }

            if (model.Dictionaries.Locations != null)
            {
                foreach (var item in model.Dictionaries.Locations)
                {
                    if (unitOfWork.Locations.FindByCode(item.Key) == null)
                    {
                        unitOfWork.Locations.Insert(new KeyValuePair <string, string>(item.Key, item.Value.detailedName));
                    }
                }
            }


            Flight flight = new Flight()
            {
                Adults        = adults,
                CurrencyId    = unitOfWork.Currencies.FindByCode(model.Meta.Currency).CurrencyId,
                Origin        = origin,
                Destination   = destionation,
                DepartureDate = DateTime.Parse(departureDate),
                ReturnDate    = DateTime.Parse(returnDate ?? DateTime.MinValue.ToString()),
                Link          = model.Meta.Links.Self,
            };

            flight.FlightId = unitOfWork.Flights.Insert(flight);

            try
            {
                foreach (var item in model.Data)
                {
                    FlightOffer flightOffer = new FlightOffer
                    {
                        Id       = item.Id,
                        Type     = item.Type,
                        FlightId = flight.FlightId,
                    };

                    var flightOfferId = unitOfWork.FlightOffers.Insert(flightOffer);
                    foreach (var offer in item.OfferItems)
                    {
                        OfferItem offerItem = new OfferItem();
                        offerItem.FlightOfferId = flightOfferId;

                        Price price = new Price
                        {
                            Total      = offer.Price.Total,
                            TotalTaxes = offer.Price.TotalTaxes,
                        };
                        offerItem.PriceId = unitOfWork.Prices.Insert(price);

                        if (offer.PricePerAdult != null)
                        {
                            Price adult = new Price
                            {
                                Total      = offer.PricePerAdult.Total,
                                TotalTaxes = offer.PricePerAdult.TotalTaxes,
                            };
                            offerItem.PricePerAdultId = unitOfWork.Prices.Insert(adult);
                        }

                        if (offer.PricePerChild != null)
                        {
                            Price child = new Price
                            {
                                Total      = offer.PricePerChild.Total,
                                TotalTaxes = offer.PricePerChild.TotalTaxes,
                            };
                            offerItem.PricePerChildId = unitOfWork.Prices.Insert(child);
                        }

                        if (offer.PricePerInfant != null)
                        {
                            Price infant = new Price
                            {
                                Total      = offer.PricePerInfant.Total,
                                TotalTaxes = offer.PricePerInfant.TotalTaxes,
                            };
                            offerItem.PricePerInfantId = unitOfWork.Prices.Insert(infant);
                        }

                        if (offer.PricePerSenior != null)
                        {
                            Price senior = new Price
                            {
                                Total      = offer.PricePerSenior.Total,
                                TotalTaxes = offer.PricePerSenior.TotalTaxes,
                            };
                            offerItem.PricePerSeniorId = unitOfWork.Prices.Insert(senior);
                        }

                        var offerItemId = unitOfWork.OfferItems.Insert(offerItem);
                        foreach (var ser in offer.Services)
                        {
                            Data.Flights.Service service = new Data.Flights.Service();
                            service.OfferItemId = offerItemId;

                            var serviceId = unitOfWork.Services.Insert(service);
                            if (ser.Segments != null)
                            {
                                foreach (var seg in ser.Segments)
                                {
                                    Segment segment = new Segment();
                                    segment.ServiceId = serviceId;

                                    FlightSegment flightSegment = new FlightSegment();
                                    flightSegment.AircraftId = unitOfWork.Aircrafts.FindByCode(seg.FlightSegment.Aircraft.Code).AircraftId;

                                    FlightEndPoint arrival = new FlightEndPoint
                                    {
                                        At         = seg.FlightSegment.Arrival.At,
                                        LocationId = unitOfWork.Locations.FindByCode(seg.FlightSegment.Arrival.IataCode).LocationId,
                                        Terminal   = seg.FlightSegment.Arrival.Terminal,
                                    };
                                    flightSegment.ArrivalId = unitOfWork.FlightEndPoints.Insert(arrival);
                                    flightSegment.CarrierId = unitOfWork.Carriers.FindByCode(seg.FlightSegment.CarrierCode).CarrierId;

                                    FlightEndPoint departure = new FlightEndPoint
                                    {
                                        At         = seg.FlightSegment.Departure.At,
                                        LocationId = unitOfWork.Locations.FindByCode(seg.FlightSegment.Departure.IataCode).LocationId,
                                        Terminal   = seg.FlightSegment.Departure.Terminal,
                                    };
                                    flightSegment.DepartureId = unitOfWork.FlightEndPoints.Insert(departure);
                                    flightSegment.Duration    = seg.FlightSegment.Duration;
                                    flightSegment.Number      = seg.FlightSegment.Number;

                                    Operation operation = new Operation
                                    {
                                        CarrierId = unitOfWork.Carriers.FindByCode(seg.FlightSegment.Operating.CarrierCode).CarrierId,
                                        Number    = seg.FlightSegment.Operating.Number,
                                    };
                                    flightSegment.OperationId = unitOfWork.Operations.Insert(operation);

                                    segment.FlightSegmentId = unitOfWork.FlightSegments.Insert(flightSegment);

                                    if (seg.FlightSegment.Stops != null)
                                    {
                                        foreach (var stop in seg.FlightSegment.Stops)
                                        {
                                            FlightStop flightStop = new FlightStop
                                            {
                                                AircraftId      = unitOfWork.Aircrafts.FindByCode(stop.NewAircraft.Code).AircraftId,
                                                ArrivalAt       = stop.ArrivalAt,
                                                CarrierId       = unitOfWork.Carriers.FindByCode(stop.IataCode).CarrierId,
                                                DepartureAt     = stop.DepartureAt,
                                                Duration        = stop.Duration,
                                                FlightSegmentId = segment.FlightSegmentId,
                                            };
                                            unitOfWork.FlightStops.Insert(flightStop);
                                        }
                                    }

                                    if (seg.PricingDetailPerAdult != null)
                                    {
                                        PricingDetail adult = new PricingDetail
                                        {
                                            Availability = seg.PricingDetailPerAdult.Availability,
                                            FareBasis    = seg.PricingDetailPerAdult.FareBasis,
                                            FareClass    = seg.PricingDetailPerAdult.FareClass,
                                            TravelClass  = seg.PricingDetailPerAdult.TravelClass,
                                        };
                                        segment.PricingDetailPerAdultId = unitOfWork.PricingDetails.Insert(adult);
                                    }

                                    if (seg.PricingDetailPerChild != null)
                                    {
                                        PricingDetail child = new PricingDetail
                                        {
                                            Availability = seg.PricingDetailPerChild.Availability,
                                            FareBasis    = seg.PricingDetailPerChild.FareBasis,
                                            FareClass    = seg.PricingDetailPerChild.FareClass,
                                            TravelClass  = seg.PricingDetailPerChild.TravelClass,
                                        };
                                        segment.PricingDetailPerChildId = unitOfWork.PricingDetails.Insert(child);
                                    }

                                    if (seg.PricingDetailPerInfant != null)
                                    {
                                        PricingDetail infant = new PricingDetail
                                        {
                                            Availability = seg.PricingDetailPerInfant.Availability,
                                            FareBasis    = seg.PricingDetailPerInfant.FareBasis,
                                            FareClass    = seg.PricingDetailPerInfant.FareClass,
                                            TravelClass  = seg.PricingDetailPerInfant.TravelClass,
                                        };
                                        segment.PricingDetailPerInfantId = unitOfWork.PricingDetails.Insert(infant);
                                    }

                                    if (seg.PricingDetailPerSenior != null)
                                    {
                                        PricingDetail senior = new PricingDetail
                                        {
                                            Availability = seg.PricingDetailPerSenior.Availability,
                                            FareBasis    = seg.PricingDetailPerSenior.FareBasis,
                                            FareClass    = seg.PricingDetailPerSenior.FareClass,
                                            TravelClass  = seg.PricingDetailPerSenior.TravelClass,
                                        };
                                        segment.PricingDetailPerSeniorId = unitOfWork.PricingDetails.Insert(senior);
                                    }

                                    var segmentId = unitOfWork.Segments.Insert(segment);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

            return(flight.FlightId);
        }
Beispiel #17
0
    private void Awake()
    {
        clickerItems           = new List <ClickerItem <Clicker> >();
        boosterItems           = new List <BoosterItem <Booster> >();
        specAmplificationItems = new List <SpecialAmplificationItem <SpecialAmplification> >();
        offerItems             = new List <OfferItem <Offer> >();

        AddClickerToList(manualClickers);
        AddClickerToList(autoClickers);
        AddClickerToList(offlineClickers);
        AddClickerToList(universalClickers);
        AddBoosterToList(timeBoosters);
        AddBoosterToList(soldierBoosters);
        AddBoosterToList(regenBoosters);
        AddBoosterToList(instantHealthBoosters);
        AddBoosterToList(defenceBoosters);
        AddSpecAmplificationToList(timeSoldierModifiers);
        AddSpecAmplificationToList(permamentSoldierBoosts);
        AddOfferToList(alienHearts);

        void AddClickerToList <T>(ClickerItem <T>[] clickerItemT) where T : Clicker
        {
            foreach (var item in clickerItemT)
            {
                ClickerItem <Clicker> clickerItem = new ClickerItem <Clicker>(item.uiInfo, item.Product);

                clickerItems.Add(clickerItem);
            }

            UI.productsCount.Add(typeof(T));
        }

        void AddBoosterToList <T>(BoosterItem <T>[] boosterItemT) where T : Booster
        {
            foreach (var item in boosterItemT)
            {
                BoosterItem <Booster> boosterItem = new BoosterItem <Booster>(item.uiInfo, item.Product);

                boosterItems.Add(boosterItem);
            }

            UI.productsCount.Add(typeof(T));
        }

        void AddSpecAmplificationToList <T>(SpecialAmplificationItem <T>[] specialAmplificationItemT) where T : SpecialAmplification
        {
            foreach (var item in specialAmplificationItemT)
            {
                SpecialAmplificationItem <SpecialAmplification> samplificationItem = new SpecialAmplificationItem <SpecialAmplification>(item.uiInfo, item.Product);

                specAmplificationItems.Add(samplificationItem);
            }

            UI.productsCount.Add(typeof(T));
        }

        void AddOfferToList <T>(OfferItem <T>[] offerItemsT) where T : Offer
        {
            foreach (var item in offerItemsT)
            {
                OfferItem <Offer> offerItem = new OfferItem <Offer>(item.uiInfo, item.Product);

                offerItems.Add(offerItem);
            }

            UI.productsCount.Add(typeof(T));
        }
    }
        public IActionResult Save(Offer entity, HashSet <OfferActiveDate> activeDates, IFormCollection form)
        {
            string strReturnMsg = "error";

            try
            {
                ModelState.Clear();
                TryValidateModel(entity);
                if (ModelState.IsValid)
                {
                    if (entity.Id == default)
                    {
                        entity.Code = UIHelper.GeneratCode(EN_Screens.Offers, _uow);
                        if (string.IsNullOrEmpty(entity.ArabicName))
                        {
                            entity.ArabicName = entity.ArabicName;
                        }
                        entity.CreationDate = DateTime.Now;
                        entity.CreatedBy    = AppSession.CurrentUser.Id;

                        //Re-ValidateModel
                        _uow.OffersRepository.Add(entity);
                    }
                    else
                    {
                        entity.ModificationDate = DateTime.Now;
                        entity.ModifiedBy       = AppSession.CurrentUser.Id;

                        //Re-ValidateModel
                        _uow.OffersRepository.Update(entity);
                    }
                    _uow.Save();

                    #region Save Active Dates
                    {
                        var selectedActiveDatesIds = activeDates.Select(ent => ent.Id).ToHashSet();
                        var deletedItems           = _uow.OfferActiveDatesRepository.GetMany(ent => ent.OfferId == entity.Id && !selectedActiveDatesIds.Contains(ent.Id)).Select(ent => ent.Id).ToHashSet();
                        if (deletedItems.Count() > 0)
                        {
                            _uow.ExecuteSqlCommand("DELETE FROM OfferActiveDates WHERE Id IN(" + string.Join(",", deletedItems) + ")");
                        }

                        foreach (var activeDate in activeDates)
                        {
                            if (!string.IsNullOrEmpty(activeDate.StrStartDate))
                            {
                                activeDate.StartDate = DateTime.ParseExact(activeDate.StrStartDate, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
                            }
                            if (!string.IsNullOrEmpty(activeDate.StrEndDate))
                            {
                                activeDate.EndDate = DateTime.ParseExact(activeDate.StrEndDate, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
                            }

                            if (activeDate.Id == default)
                            {
                                activeDate.OfferId = entity.Id;
                                _uow.OfferActiveDatesRepository.Add(activeDate);
                            }
                            else
                            {
                                _uow.OfferActiveDatesRepository.Update(activeDate);
                            }
                        }
                        _uow.Save();
                    }
                    #endregion


                    #region Save Offer Items

                    if (!string.IsNullOrEmpty(form["entity[OfferItems]"]))
                    {
                        var selectedItems = form["entity[OfferItems]"].ToString().Split(",").Select(ent => long.Parse(ent)).ToHashSet();
                        foreach (var selectedItemId in selectedItems)
                        {
                            var dbObj = _uow.OfferItemsRepository.Get(ent => ent.ItemId == selectedItemId && ent.OfferId == entity.Id);
                            if (dbObj == null)
                            {
                                var obj = new OfferItem();
                                obj.OfferId = entity.Id;
                                obj.ItemId  = selectedItemId;
                                _uow.OfferItemsRepository.Add(obj);
                            }
                        }

                        var deletedOfferItems = _uow.OfferItemsRepository.GetMany(ent => ent.OfferId == entity.Id && !selectedItems.Contains(ent.ItemId)).Select(ent => ent.Id).ToHashSet();
                        if (deletedOfferItems.Count() > 0)
                        {
                            _uow.ExecuteSqlCommand("DELETE FROM OfferItems WHERE Id IN(" + string.Join(",", deletedOfferItems) + ")");
                        }
                        _uow.Save();
                    }
                    else
                    {
                        _uow.ExecuteSqlCommand("DELETE FROM OfferItems WHERE OfferId=" + entity.Id);
                    }

                    #endregion


                    strReturnMsg = "success";
                }
            }
            catch (Exception) { }
            return(Json(new { id = entity.Id, status = strReturnMsg }));
        }
Beispiel #19
0
 public void Insert(OfferItem entity)
 {
     offerItemRepository.Insert(entity);
     unitOfWork.SaveChanges();
 }
Beispiel #20
0
 public void Delete(OfferItem entity)
 {
     offerItemRepository.Delete(entity);
     unitOfWork.SaveChanges();
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get offer item from item path
            string clubId = WebUtil.GetQueryString("clubId");
            string offerId = WebUtil.GetQueryString("offerId");

            offerItem = SitecoreHelper.GetOfferOnOfferId(offerId);
            currentClub = SitecoreHelper.GetClubOnClubId(clubId);

            if (offerItem != null && currentClub != null)
            {

                string val = Translate.Text("Please enter {0}");
                rfvName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a name")));
                revName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid name")));
                rfvEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("an email address")));
                revEmail.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid email address")));
                rfvClubName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", Translate.Text("Please select a club"));
                revClubName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", Translate.Text("Please select a club"));
                cvClubName.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", Translate.Text("Please select a club"));
                rfvPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a contact number")));
                revPhone.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", String.Format(val, Translate.Text("a valid contact number")));
                rfvHowDidYouFindUs.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", Translate.Text("Please select how you heard about us"));
                revHowDidYouFindUs.ErrorMessage = String.Format("<div class='error-msg'><p>{0}</p></div>", Translate.Text("Please select how you heard about us"));

                revEmail.ValidationExpression = Settings.EmailAddressRegularExpression;
                revName.ValidationExpression = Settings.NameRegularExpression;
                revPhone.ValidationExpression = Settings.PhoneNumberRegularExpression;
                revClubName.ValidationExpression = "^((?!" + Translate.Text("Select a club") + ").)*$";
                revHowDidYouFindUs.ValidationExpression = "^((?!" + Translate.Text("Select") + ").)*$";

                Assert.ArgumentNotNullOrEmpty(ItemPaths.Clubs, "Club root path not set");

                if (!Page.IsPostBack)
                {
                    BindDropDownLists();
                }

                this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script>
                $(function(){
                    $.va_init.functions.setupForms();
                });
                </script>"));
            }
        }
Beispiel #22
0
 public static BaseDiscountHandler CreateOfferHandler(OfferItem offerItem, PriceList priceList)
 {
     return(new ConcreteDiscountHandler(offerItem, priceList));
 }
Beispiel #23
0
 public ConcreteDiscountHandler(OfferItem offerItem, PriceList priceList)
 {
     _offerItem = offerItem;
     _priceList = priceList;
 }