public async Task <IHttpActionResult> Get([FromUri] BuyOfferFilterDto filter)
        {
            var id     = (Thread.CurrentPrincipal as UserPrincipal).Id;
            var offers = await _service.GetData(filter.GetFilter(id));

            var dto = _buyAssembler.EntityToDto(offers);

            return(Ok(dto));
        }
        public async Task <IHttpActionResult> Login([FromBody] AuthenticationDto dto)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest("Invalid data"));
            }

            var user = await _service.GetData(u => u.password == dto.Password && u.users1.UserName == dto.User.UserName);

            if (user.Count() == 1)
            {
                dto = _assembler.EntityToDto(user.First());
                return(Ok(dto));
            }

            return(BadRequest("Wrong username or password"));
        }
 public AuthenticationDto EntityToDto(users_Authetication entity)
 {
     return(new AuthenticationDto()
     {
         Id = entity.ID,
         Password = entity.password,
         User = _assembler.EntityToDto(entity.users1),
         UserId = entity.User_id
     });
 }
        public async Task <IHttpActionResult> Get(int id)
        {
            var user = await _service.GetById(id);

            if (user == null)
            {
                return(BadRequest("Entity not found"));
            }

            var info = _userAssembler.EntityToDto(user.users1);

            return(Ok(info));
        }
 public SellOfferDto EntityToDto(sell_Offer entity)
 {
     return(new SellOfferDto()
     {
         Id = entity.ID,
         Amount = entity.amount,
         SellerId = entity.seller_id,
         Name = entity.name,
         Price = (decimal?)entity.price,
         ProductId = entity.product_id,
         Product = _assembler.EntityToDto(entity.product),
         User = _userAssembler.EntityToDto(entity.users),
     });
 }
Example #6
0
 public BuyOfferDto EntityToDto(buy_Offer entity)
 {
     return(new BuyOfferDto()
     {
         Id = entity.ID,
         Amount = entity.amount,
         BuyerId = entity.buyer_id,
         Name = entity.name,
         Price = (decimal?)entity.price,
         ProductId = entity.product_id,
         Product = _assembler.EntityToDto(entity.product),
         User = _userAssembler.EntityToDto(entity.users)
     });
 }
Example #7
0
 public UserDto EntityToDto(users entity)
 {
     if (entity == null)
     {
         return(null);
     }
     return(new UserDto()
     {
         Id = entity.ID,
         FirstName = entity.First_Name,
         LastName = entity.Last_Name,
         UserName = entity.UserName,
         Rating = entity.Rating,
         Address = _assembler.EntityToDto(entity.UserAddress1),
         AddressId = entity.Address_ID
     });
 }