Exemple #1
0
        /// <summary>
        /// Получение полной информации по лодке
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BoatViewModel GetBoatInfo(int id)
        {
            Boat          b_result  = b_repository.Boat_GetById(id);
            BoatModel     bm_result = bm_repository.GetById(b_result.ModelId);
            List <byte[]> images    = null;
            List <Image>  i_result  = i_repository.GetAllByOwnerId(b_result.Id).ToList();

            if (i_result != null)
            {
                images = new List <byte[]>();
                foreach (Image image in i_result)
                {
                    images.Add(image.Content);
                }
            }
            List <RentViewModel> rents    = null;
            List <Rent>          r_result = r_repository.GetByOwnerId(b_result.Id).ToList();

            if (r_result != null)
            {
                rents = new List <RentViewModel>();
                foreach (Rent rent in r_result)
                {
                    rents.Add(new RentViewModel {
                        StatusFrom = rent.From, StatusTo = rent.To
                    });
                }
            }
            BoatViewModel boat = new BoatViewModel
            {
                ID               = b_result.Id,
                Type             = b_result.BoatType,
                Speed            = b_result.Speed,
                Cost             = b_result.Cost,
                Description      = b_result.Description,
                Kind             = b_result.Kind,
                Status           = b_result.Status,
                Owner            = b_result.OwnerId,
                BoatModel        = bm_result.Name,
                Lenght           = bm_result.Length,
                Width            = bm_result.Width,
                Displacement     = bm_result.Displacement,
                ManufacturerName = bm_result.ManufacturerName,
                Images           = images,
                Rents            = rents
            };

            return(boat);
        }
Exemple #2
0
 /// <summary>
 /// Получить исходящие заявки от пользователя
 /// </summary>
 /// <param name="account_id"></param>
 /// <returns></returns>
 public List<MessageViewModel> GetInbox(int account_id)
 {
     List<Message> comments = m_repository.GetAllOutbox(account_id).ToList();
     List<MessageViewModel> result = new List<MessageViewModel>();
     foreach (Message item in comments)
     {
         string login = a_repository.GetById(item.FromId).Login;
         int model_id = b_repository.Boat_GetById(item.BoatId).ModelId;
         string model = bm_repository.GetById(model_id).Name;
         result.Add(new MessageViewModel
         {
             Id = item.Id,
             Login = login,
             BoatId = item.BoatId,
             BoatModel = model,
             Text = item.Text,
             Date = item.Date
         });
     }
     return result;
 }