示例#1
0
        public async Task AcceptCompanyToUserAsync(int idCargo, int idGroup, string userId)
        {
            //Принятие предложения компании - пользователю о перевозке грузаЫ

            var cargo = _ctx.Cargos.Include(o => o.Id_Owner).FirstOrDefault(c => c.Id_Cargo == idCargo);

            var group = _ctx.Groups.Include(o => o.IdOwner)
                        .Include(o => o.Cars)
                        .ToList().FirstOrDefault(o => o.IdGroup == idGroup);

            var cargoInCar = new CargoInCar
            {
                Transporter   = group.Cars.FirstOrDefault(o => o.CargoType == cargo.CargoType),
                AmountOfCarog = 100,
                Cargo         = cargo
            };

            _ctx.CargoInCars.Add(cargoInCar);

            var toDel = _ctx.Requests.Where(o => o.RequestType == RequestType.CompanyOffersToUser &&
                                            o.Recip.Id == _ctx.Users.FirstOrDefault(us => us.Id == userId).Id);

            _ctx.Requests.RemoveRange(toDel);

            await SaveChangesAsync();
        }
示例#2
0
        public async Task AcceptUserToCompany(int id_Cargo, int id_Group, int id_Request)
        {
            var cargo = _ctx.Cargos.Include(o => o.Id_Owner).FirstOrDefault(c => c.Id_Cargo == id_Cargo);
            var group = _ctx.Groups.Include(o => o.IdOwner)
                        .Include(o => o.Cars)
                        .ToList().FirstOrDefault(o => o.IdGroup == id_Group);
            var cargoInCar = new CargoInCar
            {
                Transporter   = group.Cars.FirstOrDefault(o => o.CargoType == cargo.CargoType),
                AmountOfCarog = 100,
                Cargo         = cargo
            };

            _ctx.CargoInCars.Add(cargoInCar);
            Remove(id_Request);
            await SaveChangesAsync();
        }
示例#3
0
 public async Task UpdateAsync(CargoInCar cic)
 {
     _ctx.Update(cic);
     await _ctx.SaveChangesAsync();
 }