示例#1
0
        public ActionResult Edit(int id, FormCollection collection, Models.Offer offer)
        {
            try
            {
                // TODO: Add update logic here
                SOffer soffer = new SOffer();
                Persistence.Entities.Offer offerp = soffer.GetById(id);
                var category = collection["Categories"];
                offerp.CategoryId = int.Parse(category);
                foreach (var prop in offerp.GetType().GetProperties())
                {
                    if (offerp.GetType().GetProperty(prop.Name) != null)
                    {
                        var value = offerp.GetType().GetProperty(prop.Name).GetValue(offerp);
                        if (offer.GetType().GetProperty(prop.Name) != null)
                        {
                            if (offer.GetType().GetProperty(prop.Name).GetValue(offer) != null && value.ToString() != offer.GetType().GetProperty(prop.Name).GetValue(offer).ToString())
                            {
                                offerp.GetType().GetProperty(prop.Name).SetValue(offerp, offer.GetType().GetProperty(prop.Name).GetValue(offer));
                            }
                        }
                    }
                }
                //offerp.InjectFrom(offer);
                Persistence.Entities.Offer updaoofer = soffer.Update(offerp);
                UpdateOfferPhases(offerp, offer);
                return(RedirectToAction("Index", "Projects", new { id = SessionBag.Current.User.Id }));
            }
            catch (Exception er)
            {
                //offer.MessageError = er.Message;

                return(View("Error"));
            }
        }
示例#2
0
        public void TestOfferData()
        {
            Assert.True(_context.Offers.Count() == 3);
            Models.Offer offer = _context.Offers.First();
            Assert.True(offer.Equals(MockData.dataOffer.First()));

            // offers on a property
        }
        public async Task <Models.Offer> Get(string dealId, string vendorId)
        {
            Deal deal = await _dealService.GetDeal(dealId);

            Vendor vendor = await _vendorService.GetBy(vendorId);

            var offer = new Models.Offer(deal, vendor);

            return(offer.Get());
        }
        async void ToDetalsPage_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem == null)
            {
                return;
            }
            Models.Offer item = (Models.Offer)e.SelectedItem;
            ((ListView)sender).SelectedItem = null;

            await Navigation.PushModalAsync(new Views.OfferPage(new ViewsModels.OfferModel(item)));
        }
示例#5
0
            public static void Export(Models.Offer offer)
            {
                var layout = new OfferLayout
                {
                    DataContext = new OfferExportViewModel(offer),
                    FontFamily  = new FontFamily("Calibri")
                };

                IDocumentPaginatorSource dps = layout;

                RunSaveDialog(dps.DocumentPaginator, offer.OfferInformation.Title);
            }
示例#6
0
        public ActionResult AddOffer(Guid productId)
        {
            var prod      = _productsRepository.GetById(productId);
            var merchants = _merchantsRepository.SearchFor(mDto => true);

            var offer = new Models.Offer {
                ProductId = prod.Id, ProductName = prod.Name
            };

            offer.Merchants = _mapper.Map <IList <MerchantDto>, IList <Models.Merchant> >(merchants);
            ViewData.Model  = offer;

            return(View());
        }
示例#7
0
        // GET: Offer/Create
        public ActionResult Create()
        {
            try
            {
                if (SessionBag.Current.User != null)
                {
                    SCategory    scate = new SCategory();
                    Models.Offer offer = new Models.Offer();
                    offer.Categories = scate.FindAll();
                    //Request.Referrer.ToString()
                    ViewBag.UrlRef      = Request.UrlReferrer.LocalPath;
                    offer.DateIniPhase1 = DateTime.Now.Date;
                    offer.DateEndPhase1 = DateTime.Now.Date;
                    offer.DateIniPhase2 = DateTime.Now.Date;
                    offer.DateEndPhase2 = DateTime.Now.Date;

                    offer.DateIniPhase3 = DateTime.Now.Date;
                    offer.DateEndPhase3 = DateTime.Now.Date;
                    offer.DateIniPhase4 = DateTime.Now.Date;
                    offer.DateEndPhase4 = DateTime.Now.Date;


                    ViewBag.IdUser = SessionBag.Current.User.Id;
                    return(View(offer));
                }
                else
                {
                    //offerp.IdUser = "******";
                    return(RedirectToAction("Index", "Home"));
                    //throw new Exception("Favor iniciar sesion con usuario y password ");
                }
            }
            catch (Exception er)
            {
                Log4NetLogger logger2 = new Log4NetLogger();
                logger2.CurrentUser = SessionBag.Current.User.Id;
                if (Request != null)
                {
                    logger2.Error(er, Request.Path, Request.RawUrl);
                    throw new Exception(er.Message);
                }
                else
                {
                    logger2.Error(er);
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
示例#8
0
        public ActionResult AddOffer(Models.Offer newOffer)
        {
            if (!ModelState.IsValid)
            {
                return(View(newOffer));
            }

            Guid newId = Guid.NewGuid();

            _commandSender.Send <CreateOffer>(
                new CreateOffer(
                    newId, newOffer.ProductId, newOffer.MerchantId,
                    newOffer.Price, newOffer.Stock, newOffer.SKU
                    ));

            return(RedirectToAction("Details", new { id = newOffer.ProductId }));
        }
示例#9
0
        private void Hyperlink_OnClick(object sender, RoutedEventArgs e)
        {
            MainWindow mv = new MainWindow();

            //Offer offer = new Offer();

            Models.Offer offers = new Models.Offer();
            offers = (Models.Offer)(sender as Hyperlink).DataContext;
            //Offer page = new Offer(offers);
            //Offer page = new Offer(offers);
            //NavigationService nav = NavigationService.GetNavigationService(this);
            //  nav.Navigate(page);
            //offer.ShowData(offers);
            //NavigationWindow nav = this.Parent as NavigationWindow;
            //nav.Navigate(page);
            Token.setOffer(offers);
            mv.LinkNavigator.Navigate(new Uri("/Pages/Offer.xaml", UriKind.Relative), this);
        }
示例#10
0
        // GET: Offer/Edit/5
        public ActionResult Edit(int id)
        {
            SOffer soffer = new SOffer();

            Persistence.Entities.Offer offer = soffer.GetById(id);

            Models.Offer offerm = new Models.Offer();
            SCategory    scate  = new SCategory();

            offerm.Categories = scate.FindAll();
            offerm.InjectFrom(offer);
            offerm.Category = new Models.Category();
            offerm.Category.InjectFrom(offer.Category);
            AddOfferPhasesToOffer(offer, offerm);
            ViewBag.UrlRef = Request.UrlReferrer.LocalPath;
            ViewBag.IdUser = SessionBag.Current.User.Id;

            return(View(offerm));
        }
 public OfferModel(Models.Offer offer)
 {
     Item = offer;
 }
示例#12
0
        private void UpdateOfferPhases(Persistence.Entities.Offer offerp, Models.Offer offer)
        {
            List <Persistence.Entities.OfferPhases> ListOfferPhases    = new List <Persistence.Entities.OfferPhases>();
            List <Persistence.Entities.OfferPhases> ListOfferPhasesAdd = new List <Persistence.Entities.OfferPhases>();

            if (!string.IsNullOrEmpty(offer.Phase1Name))
            {
                Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
                offerphas.Id          = offerp.OfferPhases.FirstOrDefault().Id;
                offerphas.IdOffer     = offerp.Id;
                offerphas.Name        = offer.Phase1Name;
                offerphas.InitPhase   = offer.DateIniPhase1;
                offerphas.FinishPhase = offer.DateEndPhase1;
                offerphas.Value       = offer.ValuePhase1;
                offerphas.StatusPhase = Persistence.Entities.StatusPhase.EnCurso;
                ListOfferPhases.Add(offerphas);
            }

            if (!string.IsNullOrEmpty(offer.Phase2Name))
            {
                Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
                if (offerp.OfferPhases.ToArray().Length >= 2)
                {
                    offerphas.Id          = offerp.OfferPhases.ToArray()[1].Id;
                    offerphas.IdOffer     = offerp.Id;
                    offerphas.Name        = offer.Phase2Name;
                    offerphas.InitPhase   = offer.DateIniPhase2;
                    offerphas.FinishPhase = offer.DateEndPhase2;
                    offerphas.Value       = offer.ValuePhase2;
                    offerphas.StatusPhase = Persistence.Entities.StatusPhase.EnCurso;
                    ListOfferPhases.Add(offerphas);
                }
                else
                {
                    offerphas.IdOffer     = offerp.Id;
                    offerphas.Name        = offer.Phase2Name;
                    offerphas.InitPhase   = offer.DateIniPhase2;
                    offerphas.FinishPhase = offer.DateEndPhase2;
                    offerphas.Value       = offer.ValuePhase2;
                    offerphas.StatusPhase = Persistence.Entities.StatusPhase.EnCurso;
                    ListOfferPhasesAdd.Add(offerphas);
                }
            }

            if (!string.IsNullOrEmpty(offer.Phase3Name))
            {
                Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
                if (offerp.OfferPhases.ToArray().Length >= 3)
                {
                    offerphas.Id          = offerp.OfferPhases.ToArray()[2].Id;
                    offerphas.IdOffer     = offerp.Id;
                    offerphas.Name        = offer.Phase3Name;
                    offerphas.InitPhase   = offer.DateIniPhase3;
                    offerphas.FinishPhase = offer.DateEndPhase3;
                    offerphas.Value       = offer.ValuePhase3;
                    offerphas.StatusPhase = Persistence.Entities.StatusPhase.EnCurso;
                    ListOfferPhases.Add(offerphas);
                }
                else
                {
                    offerphas.IdOffer     = offerp.Id;
                    offerphas.Name        = offer.Phase3Name;
                    offerphas.InitPhase   = offer.DateIniPhase3;
                    offerphas.FinishPhase = offer.DateEndPhase3;
                    offerphas.Value       = offer.ValuePhase3;
                    offerphas.StatusPhase = Persistence.Entities.StatusPhase.EnCurso;
                    ListOfferPhasesAdd.Add(offerphas);
                }
            }

            if (!string.IsNullOrEmpty(offer.Phase4Name))
            {
                Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
                if (offerp.OfferPhases.ToArray().Length >= 4)
                {
                    offerphas.Id          = offerp.OfferPhases.ToArray()[3].Id;
                    offerphas.IdOffer     = offerp.Id;
                    offerphas.Name        = offer.Phase4Name;
                    offerphas.InitPhase   = offer.DateIniPhase4;
                    offerphas.FinishPhase = offer.DateEndPhase4;
                    offerphas.Value       = offer.ValuePhase4;
                    offerphas.StatusPhase = Persistence.Entities.StatusPhase.EnCurso;
                    ListOfferPhases.Add(offerphas);
                }
                else
                {
                    offerphas.IdOffer     = offerp.Id;
                    offerphas.Name        = offer.Phase4Name;
                    offerphas.InitPhase   = offer.DateIniPhase4;
                    offerphas.FinishPhase = offer.DateEndPhase4;
                    offerphas.Value       = offer.ValuePhase4;
                    offerphas.StatusPhase = Persistence.Entities.StatusPhase.EnCurso;
                    ListOfferPhasesAdd.Add(offerphas);
                }
            }

            SOffer soffer = new SOffer();

            soffer.UpdatePhases(ListOfferPhases, offer.Id);
            //Por si acaso hay pahases que en formulario de edicón se adicionan masfases
            soffer.InsertPhases(ListOfferPhasesAdd);
        }
示例#13
0
        private Models.Offer AddOfferPhasesToOffer(Persistence.Entities.Offer offerp, Models.Offer offer)
        {
            // List<Persistence.Entities.OfferPhases> ListOfferPhases = new List<Persistence.Entities.OfferPhases>();
            if (offerp.OfferPhases.Count > 0)
            {
                int i = 1;
                foreach (var fases in offerp.OfferPhases)
                {
                    if (i == 1)
                    {
                        offer.Phase1Name    = fases.Name;
                        offer.DateIniPhase1 = fases.InitPhase;
                        offer.DateEndPhase1 = fases.FinishPhase;
                        if (offerp.ValueFixedProject > 0)
                        {
                            offer.ValuePhase1 = fases.Value;
                        }
                        else
                        {
                            offer.PercentValuePhase1 = fases.Value;
                        }
                    }
                    else if (i == 2)
                    {
                        offer.Phase2Name    = fases.Name;
                        offer.DateIniPhase2 = fases.InitPhase;
                        offer.DateEndPhase2 = fases.FinishPhase;
                        if (offerp.ValueFixedProject > 0)
                        {
                            offer.ValuePhase2 = fases.Value;
                        }
                        else
                        {
                            offer.PercentValuePhase2 = fases.Value;
                        }
                    }
                    else if (i == 3)
                    {
                        offer.Phase3Name    = fases.Name;
                        offer.DateIniPhase3 = fases.InitPhase;
                        offer.DateEndPhase3 = fases.FinishPhase;
                        if (offerp.ValueFixedProject > 0)
                        {
                            offer.ValuePhase3 = fases.Value;
                        }
                        else
                        {
                            offer.PercentValuePhase3 = fases.Value;
                        }
                    }
                    else if (i == 4)
                    {
                        offer.Phase4Name    = fases.Name;
                        offer.DateIniPhase4 = fases.InitPhase;
                        offer.DateEndPhase4 = fases.FinishPhase;
                        if (offerp.ValueFixedProject > 0)
                        {
                            offer.ValuePhase4 = fases.Value;
                        }
                        else
                        {
                            offer.PercentValuePhase4 = fases.Value;
                        }
                    }
                    i += 1;
                }
            }

            return(offer);
            //if (!string.IsNullOrEmpty(offer.Phase1Name))
            //{
            //    Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
            //    offerphas.IdOffer = offerp.Id;
            //    offerphas.Name = offer.Phase1Name;
            //    offerphas.InitPhase = offer.DateIniPhase1;
            //    offerphas.FinishPhase = offer.DateEndPhase1;
            //    offerphas.Value = offer.ValuePhase1;
            //    offerphas.StatusPhase = (short)StatusPhase.Aplicada;
            //    ListOfferPhases.Add(offerphas);
            //}

            //if (!string.IsNullOrEmpty(offer.Phase2Name))
            //{
            //    Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
            //    offerphas.IdOffer = offerp.Id;
            //    offerphas.Name = offer.Phase2Name;
            //    offerphas.InitPhase = offer.DateIniPhase2;
            //    offerphas.FinishPhase = offer.DateEndPhase2;
            //    offerphas.Value = offer.ValuePhase2;
            //    offerphas.StatusPhase = (short)StatusPhase.Aplicada;
            //    ListOfferPhases.Add(offerphas);
            //}

            //if (!string.IsNullOrEmpty(offer.Phase3Name))
            //{
            //    Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
            //    offerphas.IdOffer = offerp.Id;
            //    offerphas.Name = offer.Phase3Name;
            //    offerphas.InitPhase = offer.DateIniPhase3;
            //    offerphas.FinishPhase = offer.DateEndPhase3;
            //    offerphas.Value = offer.ValuePhase3;
            //    offerphas.StatusPhase = (short)StatusPhase.Aplicada;
            //    ListOfferPhases.Add(offerphas);
            //}

            //if (!string.IsNullOrEmpty(offer.Phase4Name))
            //{
            //    Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
            //    offerphas.IdOffer = offerp.Id;
            //    offerphas.Name = offer.Phase4Name;
            //    offerphas.InitPhase = offer.DateIniPhase4;
            //    offerphas.FinishPhase = offer.DateEndPhase4;
            //    offerphas.Value = offer.ValuePhase4;
            //    offerphas.StatusPhase = (short)StatusPhase.Aplicada;
            //    ListOfferPhases.Add(offerphas);
            //}
        }
示例#14
0
        private void CreateOfferPhases(Persistence.Entities.Offer offerp, Models.Offer offer, string[] formatdate, FormCollection collection)
        {
            List <Persistence.Entities.OfferPhases> ListOfferPhases = new List <Persistence.Entities.OfferPhases>();
            DateTime dateini, datefin;

            if (!string.IsNullOrEmpty(offer.Phase1Name))
            {
                if (offer.PercentValuePhase1 != 0 && offer.ValuePhase1 == 0)
                {
                    offer.ValuePhase1 = offer.PercentValuePhase1;
                }

                Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
                offerphas.IdOffer = offerp.Id;
                offerphas.Name    = offer.Phase1Name;
                DateTime.TryParseExact(collection["DateIniPhase1"], formatdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateini); //DateTime.ParseExact(offer.DateIniPhase1.ToShortDateString(), formatdate, CultureInfo.InvariantCulture);
                DateTime.TryParseExact(collection["DateEndPhase1"], formatdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out datefin); //DateTime.ParseExact(offer.DateEndPhase1.ToShortDateString(), formatdate, CultureInfo.InvariantCulture);
                offerphas.InitPhase   = dateini;
                offerphas.FinishPhase = datefin;
                offerphas.Value       = offer.ValuePhase1;
                offerphas.StatusPhase = Persistence.Entities.StatusPhase.SinIniciar;
                ListOfferPhases.Add(offerphas);
            }

            if (!string.IsNullOrEmpty(offer.Phase2Name))
            {
                if (offer.PercentValuePhase2 != 0 && offer.ValuePhase2 == 0)
                {
                    offer.ValuePhase2 = offer.PercentValuePhase2;
                }
                Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
                offerphas.IdOffer = offerp.Id;
                offerphas.Name    = offer.Phase2Name;
                DateTime.TryParseExact(collection["DateIniPhase2"], formatdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateini); //DateTime.ParseExact(offer.DateIniPhase1.ToShortDateString(), formatdate, CultureInfo.InvariantCulture);
                DateTime.TryParseExact(collection["DateEndPhase2"], formatdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out datefin); //DateTime.ParseExact(offer.DateEndPhase1.ToShortDateString(), formatdate, CultureInfo.InvariantCulture);
                offerphas.InitPhase   = dateini;
                offerphas.FinishPhase = datefin;
                offerphas.Value       = offer.ValuePhase2;
                offerphas.StatusPhase = Persistence.Entities.StatusPhase.SinIniciar;
                ListOfferPhases.Add(offerphas);
            }

            if (!string.IsNullOrEmpty(offer.Phase3Name))
            {
                if (offer.PercentValuePhase3 != 0 && offer.ValuePhase3 == 0)
                {
                    offer.ValuePhase3 = offer.PercentValuePhase3;
                }
                Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
                offerphas.IdOffer = offerp.Id;
                offerphas.Name    = offer.Phase3Name;
                DateTime.TryParseExact(collection["DateIniPhase3"], formatdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateini); //DateTime.ParseExact(offer.DateIniPhase1.ToShortDateString(), formatdate, CultureInfo.InvariantCulture);
                DateTime.TryParseExact(collection["DateEndPhase3"], formatdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out datefin); //DateTime.ParseExact(offer.DateEndPhase1.ToShortDateString(), formatdate, CultureInfo.InvariantCulture);
                offerphas.InitPhase   = dateini;
                offerphas.FinishPhase = datefin;
                offerphas.Value       = offer.ValuePhase3;
                offerphas.StatusPhase = Persistence.Entities.StatusPhase.SinIniciar;
                ListOfferPhases.Add(offerphas);
            }

            if (!string.IsNullOrEmpty(offer.Phase4Name))
            {
                if (offer.PercentValuePhase4 != 0 && offer.ValuePhase4 == 0)
                {
                    offer.ValuePhase4 = offer.PercentValuePhase4;
                }

                Persistence.Entities.OfferPhases offerphas = new Persistence.Entities.OfferPhases();
                offerphas.IdOffer = offerp.Id;
                offerphas.Name    = offer.Phase4Name;
                DateTime.TryParseExact(collection["DateIniPhase4"], formatdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateini); //DateTime.ParseExact(offer.DateIniPhase1.ToShortDateString(), formatdate, CultureInfo.InvariantCulture);
                DateTime.TryParseExact(collection["DateEndPhase4"], formatdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out datefin); //DateTime.ParseExact(offer.DateEndPhase1.ToShortDateString(), formatdate, CultureInfo.InvariantCulture);
                offerphas.InitPhase   = dateini;
                offerphas.FinishPhase = datefin;
                offerphas.Value       = offer.ValuePhase4;
                offerphas.StatusPhase = Persistence.Entities.StatusPhase.SinIniciar;
                ListOfferPhases.Add(offerphas);
            }

            SOffer soffer = new SOffer();

            soffer.InsertPhases(ListOfferPhases);
        }
示例#15
0
        public ActionResult Create(FormCollection collection, Models.Offer offer)
        {
            string[] formatdate = Helper.ReadSetting("FormatDate").Split(',');
            DateTime dateini, datefin;

            DateTime.TryParseExact(collection["DateIniPhase1"], formatdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateini); //DateTime.ParseExact(offer.DateIniPhase1.ToShortDateString(), formatdate, CultureInfo.InvariantCulture);
            DateTime.TryParseExact(collection["DateEndPhase1"], formatdate, CultureInfo.InvariantCulture, DateTimeStyles.None, out datefin); //DateTime.ParseExact(offer.DateEndPhase1.ToShortDateString(), formatdate, CultureInfo.InvariantCulture);

            Persistence.Entities.Offer offerp = new Persistence.Entities.Offer();

            var category = collection["Categories"];

            try
            {
                // TODO: Add insert logic here
                SOffer soffer = new SOffer();



                offerp.InjectFrom(offer);

                if (SessionBag.Current.User != null)
                {
                    offerp.IdUser  = SessionBag.Current.User.Id;
                    ViewBag.IdUser = offerp.IdUser;
                }
                else
                {
                    //offerp.IdUser = "******";
                    RedirectToAction("Index", "Home");
                    //throw new Exception("Favor iniciar sesion con usuario y password ");
                }
                offerp.CategoryId = int.Parse(category);
                if (offer.ValueFixedProject > 0 && offer.RangoValor == 0)
                {
                    offerp.PrecioFijo = true;
                    offerp.RangoValor = GetRangoValor(offerp.ValueFixedProject);
                }
                else
                {
                    offerp.PrecioFijo = false;
                }
                offerp = soffer.Insert(offerp);

                CreateOfferPhases(offerp, offer, formatdate, collection);

                if (SessionBag.Current.User.Freelance)
                {
                    return(RedirectToAction("Index", new { id = SessionBag.Current.User.Id }));
                }
                else
                {
                    return(RedirectToAction("Index", new { id = SessionBag.Current.User.Id }));
                }
            }
            catch (Exception er)
            {
                Log4NetLogger logger2 = new Log4NetLogger();
                logger2.CurrentUser = SessionBag.Current.User.Id;
                if (Request != null)
                {
                    logger2.Error(er, Request.Path, Request.RawUrl);
                    //throw new Exception(er.Message);
                }
                else
                {
                    logger2.Error(er);
                }
            }

            return(RedirectToAction("Index", new { id = SessionBag.Current.User.Id }));
        }