public bool AddResident(ResidentTable resident) { if (resident != null) { using (ApplicationDatabaseEntities3 dataContext = new ApplicationDatabaseEntities3()) { dataContext.ResidentTables.Add(resident); dataContext.SaveChanges(); return(true); } } return(false); }
public JsonResult AddPackage(string resident) { if (resident != null) { using (ApplicationDatabaseEntities3 dataContext = new ApplicationDatabaseEntities3()) { dynamic data = JObject.Parse(resident); PackageList t = dataContext.PackageLists.FirstOrDefault <PackageList>(); // t.FullName = (string)data.FullName; // t.Location = data.Location; // t.Description = data.Description; // t.DateIn = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; // t.Status = "Queued"; var table = new PackageList { FullName = data.FullName, Location = data.Location, StudentID = data.Id, Description = data.Description, DateIn = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds, Status = "Queued" }; dataContext.PackageLists.Add(table); dataContext.Entry(table).State = System.Data.Entity.EntityState.Added; dataContext.SaveChanges(); return(new JsonResult() { Data = new { data = "1" }, JsonRequestBehavior = JsonRequestBehavior.DenyGet }); } } return(new JsonResult() { Data = new { dataBaseStatus = "0" }, JsonRequestBehavior = JsonRequestBehavior.DenyGet }); }