Esempio n. 1
0
        public async Task <IActionResult> PutDriver([FromRoute] int id, [FromBody] Driver driver)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != driver.Id)
            {
                return(BadRequest());
            }

            _context.Entry(driver).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DriverExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> RemovePassenger(string Id, string PassngerId)
        {
            var TaxiService = await _context.TaxiServices.Undelited()
                              .Include(t => t.Driver)
                              .Include(c => c.Passnegers)
                              .FirstOrDefaultAsync(c => c.Id == Id & c.Driver.ContractorId == User.GetContractor().Id);

            if (TaxiService == null)
            {
                return(NotFound());
            }

            var passnger = TaxiService.Passnegers.FirstOrDefault(c => c.Id == PassngerId);

            if (passnger == null)
            {
                ViewBag.msg = "مسافری با این مشخصات  یافت نشد";
                return(View(nameof(Passengers), new { id = Id }));
            }

            passnger.TaxiServiceId         = null;
            _context.Entry(passnger).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Passengers), new { id = Id }));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "TaxiID,TaxiModel,Color,RegisterNumber,TaxiType")] Taxi taxi)
 {
     if (ModelState.IsValid)
     {
         db.Entry(taxi).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(taxi));
 }
Esempio n. 4
0
 public async Task <T> Update(T entity)
 {
     _taxiContext.Entry(entity).State = EntityState.Modified;
     try
     {
         await _taxiContext.SaveChangesAsync();
     }
     catch
     {
         return(null);
     }
     return(entity);
 }
Esempio n. 5
0
 /// <summary>
 ///     Modify existing user in data base
 /// </summary>
 /// <param name="user">user</param>
 public void Update(User user)
 {
     _db.Entry(user).State = EntityState.Modified;
 }
Esempio n. 6
0
 /// <summary>
 ///     Modify existing order in database
 /// </summary>
 /// <param name="order">existing order</param>
 public void Update(Order order)
 {
     _db.Entry(order).State = EntityState.Modified;
 }