public override bool Equals(object obj) { PrintRequest other = obj as PrintRequest; if (other == null) { return(false); } return(other.ID == this.ID); }
public int RequestPrinting(int contestID, string content, int copies) { using (DB db = new DB()) { CheckRole(db, UserRole.Competitor); Contest contest = db.Contests.Find(contestID); if (contest == null) throw new FaultException<NotFoundError>(new NotFoundError { ID = contestID, Type = "Contest" }); if (!contest.PrintingEnabled) throw new FaultException<AccessDeniedError>(new AccessDeniedError(), "printing is not enabled"); if (contest.StartTime > DateTime.Now || contest.EndTime < DateTime.Now) throw new FaultException<AccessDeniedError>(new AccessDeniedError(), "Out of contest time"); PrintRequest request = new PrintRequest { Content = content, ContestID = contestID, Copies = copies, Status = PrintRequestStatus.Pending, Time = DateTime.Now, UserID = CurrentUser.ID }; db.PrintRequests.Add(request); db.SaveChanges(); if (NewPrintRequest != null) { System.Threading.Tasks.Task.Factory.StartNew(() => NewPrintRequest(request.ID)); } foreach (var s in App.Clients.Values.Where(s => s.SessionMode == LocalCenaServer.SessionType.Server)) { System.Threading.Tasks.Task.Factory.StartNew(() => s.Callback.NewPrint(request.ID)); } return request.ID; } }