Ejemplo n.º 1
0
        public async Task <IActionResult> Create(CreateLotModel model)
        {
            if (ModelState.IsValid)
            {
                var lot = new Lot
                {
                    AppUserId = HttpContext.UserId(),
                    CreatedAt = DateTime.UtcNow
                };

                SetLotModel(model, lot);
                await AddImage(lot, model.Image);

                await _repository.Add(lot);

                return(RedirectToAction("Index", "Home"));
            }

            var categories = await _categoryRepository.GetAll();

            ViewBag.Categories = new SelectList(categories, "Id", "Name");
            ModelState.AddModelError(string.Empty, "Fill the blanks");

            return(View());
        }
 public void AddLot(Lot lot)
 {
     if (lot != null)
     {
         lotRepository.Add(lot);
         Save();
     }
 }
Ejemplo n.º 3
0
        public async Task <LotModel> CreateLot(LotModel filter)
        {
            Data.Contracts.Entities.Lot lot = _mapperAdapter.Map <Lot>(filter);

            Lot result = await _lotRepository.Add(lot);

            SentMessageToQueue(result.Id);

            var savedLot = _mapperAdapter.Map <LotModel>(result);

            return(savedLot);
        }
Ejemplo n.º 4
0
        public void AddLot(
            string symbol,
            DateTime purchaseDate,
            decimal purchasePrice,
            string notes = null
            )
        {
            using (var events = _eventManagerSource.Create())
            {
                var existingInstrument = _instrumentRepository.GetById(symbol);

                var newLot = existingInstrument != null
                    ? LotFactory.NewLotForExistingInstrument(existingInstrument, purchaseDate, purchasePrice, notes, events)
                    : LotFactory.NewLotForNewInstrument(symbol, purchaseDate, purchasePrice, notes, events);

                _lotRepository.Add(newLot);
            }
        }