Ejemplo n.º 1
0
        public IActionResult Edit(DriverBasicEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                DriverBasic driverBasic = _context.DriverBasics.FirstOrDefault(e => e.Id == model.Id);
                driverBasic.Id              = model.Id;
                driverBasic.FirstName       = driverBasic.FirstName;
                driverBasic.LastName        = driverBasic.LastName;
                driverBasic.EmiratesId      = driverBasic.EmiratesId;
                driverBasic.WhatsappNo      = driverBasic.WhatsappNo;
                driverBasic.MobileNo        = driverBasic.MobileNo;
                driverBasic.InternationalNo = driverBasic.InternationalNo;
                driverBasic.Language        = driverBasic.Language;
                //driverBasic.Picture = uniqueFileName;
                driverBasic.Nationality        = driverBasic.Nationality;
                driverBasic.DateOfBirth        = driverBasic.DateOfBirth;
                driverBasic.DateOfJoining      = driverBasic.DateOfJoining;
                driverBasic.PassportNo         = driverBasic.PassportNo;
                driverBasic.PassportExpiryDate = driverBasic.PassportExpiryDate;
                driverBasic.VisaExpiry         = driverBasic.VisaExpiry;
                driverBasic.ResidenceCountry   = driverBasic.ResidenceCountry;
                driverBasic.CityName           = driverBasic.CityName;
                driverBasic.Address1           = driverBasic.Address1;
                driverBasic.Address2           = driverBasic.Address2;
                driverBasic.DriverType         = driverBasic.DriverType;
                driverBasic.Company            = driverBasic.Company;


                try
                {
                    _context.Update(model);
                    _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DriverExists(model.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
            //return View(student);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var driverBasic = await _context.DriverBasics.FindAsync(id);

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

            DriverBasicEditViewModel driverBasicEditViewModel = new DriverBasicEditViewModel
            {
                Id              = driverBasic.Id,
                FirstName       = driverBasic.FirstName,
                LastName        = driverBasic.LastName,
                EmiratesId      = driverBasic.EmiratesId,
                WhatsappNo      = driverBasic.WhatsappNo,
                MobileNo        = driverBasic.MobileNo,
                InternationalNo = driverBasic.InternationalNo,
                Language        = driverBasic.Language,
                //Picture = uniqueFileName,
                Nationality        = driverBasic.Nationality,
                DateOfBirth        = driverBasic.DateOfBirth,
                DateOfJoining      = driverBasic.DateOfJoining,
                PassportNo         = driverBasic.PassportNo,
                PassportExpiryDate = driverBasic.PassportExpiryDate,
                VisaExpiry         = driverBasic.VisaExpiry,
                ResidenceCountry   = driverBasic.ResidenceCountry,
                CityName           = driverBasic.CityName,
                Address1           = driverBasic.Address1,
                Address2           = driverBasic.Address2,
                DriverType         = driverBasic.DriverType,
                Company            = driverBasic.Company,
            };

            return(View(driverBasicEditViewModel));
        }