public RestApiResult DeleteTrashRecord(JObject json) { if (json == null) { return(new RestApiResult { StatusCode = HttpStatusCode.BadRequest }); } var trashes = json.Value <JArray>("trashes"); List <TrashInformation> trashList = new List <TrashInformation>(); foreach (int trash in trashes) { TrashInformation oldTrash = ClarityDB.Instance.TrashInformations.FirstOrDefault(x => x.ID == trash); if (oldTrash == null) { return(new RestApiResult { StatusCode = HttpStatusCode.BadRequest }); } oldTrash.ModifiedDate = DateTime.Now; oldTrash.IsDisabled = true; trashList.Add(oldTrash); } ClarityDB.Instance.SaveChanges(); return(new RestApiResult { StatusCode = HttpStatusCode.OK, Json = BuildJsonArray(trashList) }); }
public RestApiResult ImportTrashRecord(JObject json) { if (json == null) { return(new RestApiResult { StatusCode = HttpStatusCode.BadRequest }); } var trashes = json.Value <JArray>("trashes"); List <TrashInformation> trashList = new List <TrashInformation>(); foreach (var trash in trashes) { TrashInformation newTrash = new TrashInformation(); newTrash.ApplyJson(trash); TrashInformation oldTrash = ClarityDB.Instance.TrashInformations.FirstOrDefault(x => x.TrashID == newTrash.TrashID); if (oldTrash == null) { newTrash.ModifiedDate = DateTime.Now; trashList.Add(newTrash); ClarityDB.Instance.TrashInformations.Add(newTrash); } } ClarityDB.Instance.SaveChanges(); return(new RestApiResult { StatusCode = HttpStatusCode.OK, Json = BuildJsonArray(trashList) }); }