// // GET: /Device/Create public ActionResult Create() { ViewBag.AndroidVers = new SelectList(db.AndroidVers, "Version", "Version"); ViewBag.ModelNos = new SelectList(db.ModelNos, "Number", "Number"); Device device = new Device(); device.PassCode = Guid.NewGuid().ToString(); return View(device); }
public ActionResult Create(Device device) { if (ModelState.IsValid) { device.CreationDate = DateTime.Now; db.Devices.Add(device); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.AndroidVers = new SelectList(db.AndroidVers, "Version", "Version"); ViewBag.ModelNos = new SelectList(db.ModelNos, "Number", "Number"); return View(device); }
public ActionResult Edit(Device data) { if (ModelState.IsValid) { Device device = db.Devices.Find(data.ID); device.AndriodVer = data.AndriodVer; device.CustomerID = data.CustomerID; device.DefaultURL = data.DefaultURL; device.DeploymentDate = data.DeploymentDate; device.DeviceCode = data.DeviceCode; device.DeviceType = data.DeviceType; device.ExtDate1 = data.ExtDate1; device.ExtDate2 = data.ExtDate2; device.ExtDate3 = data.ExtDate3; device.ExtDec1 = data.ExtDec1; device.ExtDec2 = data.ExtDec2; device.ExtDec3 = data.ExtDec3; device.ExtString1 = data.ExtString1; device.ExtString2 = data.ExtString2; device.ExtString3 = data.ExtString3; device.ModelNo = data.ModelNo; device.OfflineChannel = data.OfflineChannel; device.OfflineChannelValidFrom = data.OfflineChannelValidFrom; device.OfflineChannelValidTo = data.OfflineChannelValidTo; device.PassCode = data.PassCode; device.Remarks = data.Remarks; db.Entry(device).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(data); }