public ActionResult <IEnumerable <Delivery> > Get() { var domModel = new DeliveryDomainModel { DeliveryId = Guid.NewGuid().ToString(), LoadDate = DateTimeOffset.Now }; var delvry = new Delivery { Id = domModel.DeliveryId, Data = JsonConvert.SerializeObject(domModel) }; var y = new DeliveryApproval { Id = Guid.NewGuid().ToString(), Delivery = delvry }; _dbContext.DeliveryApprovals.Add(y); _dbContext.SaveChanges(); try { var abc = _dbContext.DeliveryApprovals.First(); var delivery = _dbContext .Deliveries .Include(x => x.DeliveryApproval) .ToList(); var reslt = delivery .Where(d => d.DomainModel.LoadDate >= DateTimeOffset.Now.AddDays(-1)) .ToList(); return(reslt); } catch (Exception e) { Console.WriteLine(e); throw; } }
public ActionResult AddPermission([FromBody] Permission permission) { var res = CheckToken(HttpContext); if (!res.Value) { return(res.Result); } if (permission.ObjectId != 0 && permission.SubjectId != 0) { dbContext.Permissions.Add(permission); dbContext.SaveChanges(); return(StatusCode(200)); } else { return(StatusCode(400)); } }