public async Task <IHttpActionResult> SaveCompany(Company model)
        {
            var comp = await _service.SaveCompany(model);

            await _context.SaveChangesAsync();

            return(Ok(comp));
        }
        public async Task ChangeAvailable(int id, bool act = false)
        {
            var vehicle = await _context.Vehicles
                                        .Where(v => v.Id == id)
                                        .FirstOrDefaultAsync();
            Validate(vehicle);

            vehicle.Available = act;

            await _context.SaveChangesAsync();
        }
Exemple #3
0
        public async Task <int> SaveTravel(TravelDto model)
        {
            var travel = new Travel()
            {
                DestinyId        = model.DestinyId,
                DurationStr      = model.DurationStr,
                LastChange       = DateTime.Now.ToShortDateString(),
                PersonId         = model.PersonId,
                TotalKmStr       = model.TotalKm,
                TotalKm          = decimal.Parse(model.TotalKm.Replace(" km", "")),
                RegistrationDate = DateTime.Now.ToShortDateString(),
                OriginId         = model.OriginId,
                Duration         = DateTime.Now.AddSeconds(model.DurationValue),
                UserId           = 1,
            };

            await _context.Travels.AddAsync(travel);

            await _context.SaveChangesAsync();

            return(travel.Id);
        }