Example #1
0
        public void Update(LotDto lot)
        {
            var orm = _lotRepository.GetById(lot.LotId);

            orm = lot.ToDal(orm);
            _lotRepository.Update(orm);
        }
 public LotViewModel CreateLotViewModel(LotDto lotDto)
 {
     return(new LotViewModel
     {
         Name = lotDto.Name,
         Price = lotDto.Price,
         Location = lotDto.Location,
         Image = lotDto.Image,
         DateOfUpdate = lotDto.DateOfUpdate,
         FilterId = lotDto.FilterId,
         Link = lotDto.Link
     });
 }
Example #3
0
 public Lot CreateLot(LotDto lotDto)
 {
     return(new Lot
     {
         FilterId = lotDto.FilterId,
         Name = lotDto.Name,
         Price = lotDto.Price,
         Location = lotDto.Location,
         Image = lotDto.Image,
         Link = lotDto.Link,
         SourceId = lotDto.SourceId,
         DateOfFound = lotDto.DateOfFound,
         DateOfUpdate = lotDto.DateOfUpdate,
         Id = lotDto.Id
     });
 }
Example #4
0
        public async Task <LotDto> AddLot(LotDto lotData, int shopId)
        {
            using (var db = new BuckwheatContext())
            {
                Shop shop = await db.Shops.FirstOrDefaultAsync(x => x.Id == shopId);

                if (shop == null)
                {
                    throw new ArgumentException($"Shop with id {shopId} was not found in the database.");
                }
                Lot lot = mapper.Map <LotDto, Lot>(lotData);
                lot.Shop = shop;

                await db.Lots.AddAsync(lot);

                await db.SaveChangesAsync();

                return(mapper.Map <Lot, LotDto>(lot));
            }
        }
Example #5
0
 public static Lot ToDal(this LotDto dto, Lot orm) => Mapper.Map(dto, orm);
Example #6
0
 public static Lot ToDal(this LotDto dto) => Mapper.Map <Lot>(dto);
Example #7
0
 public LotDto AddItem(LotDto lot)
 {
     return(_lotRepository.Create(lot.ToDal()).ToDto());
 }
Example #8
0
 public static LotViewModel ToVm(this LotDto dto) => Mapper.Map <LotViewModel>(dto);