public override Task <ActionResponse> DoReportMember(MemberReport r, ServerCallContext context) { var response = new ActionResponse(); try { var z = from x in db.Members join u in db.Users on x.UserId equals u.Id where u.Name == r.ReportingMember.User.Name select x; var q = from x in db.Members join u in db.Users on x.UserId equals u.Id join y in db.Members on r.ReportedMember.User.Name equals y.User.Name where u.Name == r.ReportingMember.User.Name select new MemberReport { ReportedMember = y, ReportingMember = x, Reason = r.Reason }; db.Add(q.First()); db.SaveChanges(); response.Result = (int)HttpStatusCode.OK; } catch { response.Result = (int)HttpStatusCode.Forbidden; } return(Task.FromResult(response)); }
public static Task <T> GenericCreate <T>(this IGenericCRUD i, Need4Context db, T inputObject) { bool created = db.Database.EnsureCreated(); db.Add(inputObject); db.SaveChanges(); return(Task.FromResult(inputObject)); }
public override Task <ActionResponse> CreateTrade(Trade request, ServerCallContext context) { //using Need4Context db = new Need4Context(); bool created = db.Database.EnsureCreated(); //Console.WriteLine("Database was created (true), or existing (false): {0}", created); int result; try { db.Add(request); db.SaveChanges(); result = (int)HttpStatusCode.OK; } catch { result = (int)HttpStatusCode.Forbidden; } return(Task.FromResult(new ActionResponse { Result = result })); }