Exemplo n.º 1
0
        public ActionResult Edit(int id, IFormCollection collection)
        {
            try
            {
                using RDATContext context = new RDATContext();

                Company _company = context.Companys.Where(c => c.Id == id).FirstOrDefault();

                _company.Name               = collection["Company.Name"];
                _company.Phone              = collection["Company.Phone"];
                _company.Fax                = collection["Company.Fax"];
                _company.AddressLine1       = collection["Company.AddressLine1"];
                _company.AddressLine2       = collection["Company.AddressLine2"];
                _company.City               = collection["Company.City"];
                _company.State              = collection["Company.State"];
                _company.Zip                = collection["Company.Zip"];
                _company.Email              = collection["Company.Email"];
                _company.Dot                = collection["Company.Dot"];
                _company.RepresentativeName = collection["Company.RepresentativeName"];
                _company.Status             = collection["Company.Status"];

                _company.Modified = DateTime.Now;

                context.Update(_company);
                context.SaveChanges();

                // return data;
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("id,ActivePool,DrugPercentage,DrugTestDate,AlcoholPercentage,AlcoholTestDate")] CreateBatch createBatch)
        {
            if (id != createBatch.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(createBatch);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CreateBatchExists(createBatch.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(createBatch));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Batch_Id,Selectiondatedrug,Selectiondatealcohol,Reported_Results,ResultsDate,SSN,Specimen_Id,ClosedDate,Test_Process_Id,Driver_Id,Test_Type,Drug_Percentage,Alcohol_Percentage,Created,Modified,Status,isDelete")] TestingLog testingLog)
        {
            if (id != testingLog.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(testingLog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TestingLogExists(testingLog.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(testingLog));
        }
Exemplo n.º 4
0
        public ActionResult Edit(int id, IFormCollection collection)
        {
            CreateDriverViewModel _model = new CreateDriverViewModel();
            Driver _driver = new Driver();

            try
            {
                using RDATContext context = new RDATContext();

                _driver = context.Drivers.Where(d => d.Id == id).FirstOrDefault();

                _driver.DriverName   = collection["Driver.DriverName"];
                _driver.Phone        = collection["Driver.Phone"];
                _driver.Fax          = collection["Driver.Fax"];
                _driver.AddressLine1 = collection["Driver.AddressLine1"];
                _driver.AddressLine2 = collection["Driver.AddressLine2"];
                _driver.City         = collection["Driver.City"];
                _driver.State        = collection["Driver.State"];
                _driver.Zipcode      = collection["Driver.Zipcode"];
                _driver.Email        = collection["Driver.Email"];
                _driver.CDL          = collection["Driver.CDL"];
                _driver.Cell         = collection["Driver.Cell"];

                if (Int32.TryParse(collection["Driver.Company_id"], out int result))
                {
                    _driver.Company_id = Int32.Parse(collection["Driver.Company_id"]);
                }
                ;


                _driver.EnrollmentDate = DateTime.Parse(collection["Driver.EnrollmentDate"]);

                if (DateTime.TryParse(collection["Driver.TerminationDate"], out DateTime resultDate))
                {
                    _driver.TerminationDate = DateTime.Parse(collection["Driver.TerminationDate"]);
                }

                context.Update(_driver);
                context.SaveChanges();

                // return data;
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                using RDATContext context = new RDATContext();
                List <SelectListItem> states = context.States.OrderBy(s => s.StateName).Select(a =>
                                                                                               new SelectListItem
                {
                    Value = a.Id.ToString(),
                    Text  = a.StateName
                }).ToList();
                _model.States = states;

                _model.Driver = _driver;
                return(View(_model));
            }
        }
Exemplo n.º 5
0
        public ActionResult Favorite(int id)
        {
            var thisID = id;

            using RDATContext context = new RDATContext();

            Company _company = context.Companys.Where(c => c.Id == id).FirstOrDefault();

            _company.isFavorite = !_company.isFavorite;

            context.Update(_company);
            context.SaveChanges();

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 6
0
        public ActionResult Favorite(int id)
        {
            var thisID = id;

            using RDATContext context = new RDATContext();

            try
            {
                Driver _driver = context.Drivers.Where(c => c.Id == id).FirstOrDefault();

                _driver.isFavorite = !_driver.isFavorite;

                context.Update(_driver);
                context.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }


            return(RedirectToAction(nameof(Index)));
        }