public JsonResult Delete(int id) { DeviceCardMap deviceCardMap = db.DeviceCardMaps.Find(id); if (deviceCardMap == null) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { jobId = -1 })); } db.DeviceCardMaps.Remove(deviceCardMap); db.SaveChanges(); return(Json("")); }
public JsonResult Edit(DeviceCardMap deviceCardMap) { var dbDeviceCard = db.DeviceCardMaps.Find(deviceCardMap.Id); if (dbDeviceCard != null && ModelState.IsValid) { dbDeviceCard.AssignTime = deviceCardMap.AssignTime; dbDeviceCard.ExpireTime = deviceCardMap.ExpireTime; dbDeviceCard.StatusId = deviceCardMap.StatusId; db.SaveChanges(); return(Json(deviceCardMap)); } Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json("Invalid Model State")); }
public JsonResult Create(DeviceCardMap deviceCardMap) { if (deviceCardMap.ExpireTime == DateTime.MinValue) { deviceCardMap.ExpireTime = DateTime.MaxValue; } if (ModelState.IsValid) { db.DeviceCardMaps.Add(deviceCardMap); db.SaveChanges(); return(Json(deviceCardMap)); } Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json("Invalid Model State")); }