public void UpdateProposalStatus(string bidId, string status) { UnitOfWork uow = new UnitOfWork(); StudentProblemBid bid = uow.StudentProblemBids.GetByID(bidId); if (status == "viewed") { bid.Status = (int)BidStatus.Viewed; } else if (status == "accept") { StudentProblem problem = uow.StudentProblems.GetByID(bid.ProblemID); if (Common.UserHasCredits(problem.StudentID, (decimal)problem.HoursNeeded)) { bid.Status = (int)BidStatus.Offered; problem.Status = (int)ProblemStatus.BidAccepted; Common.AddNotification("Your proposal has been accepted by " + Session["UserName"].ToString(), "", Session["UserId"].ToString(), bid.UserID, "/bid/detail/" + bid.BidID, (int)NotificationType.Bid); } else { ModelState.AddModelError("error", Resources.Resources.MsgNoBalance); } } else if (status == "decline") { bid.Status = (int)BidStatus.Declined; Common.AddNotification("Your proposal has been declined.", "", Session["UserId"].ToString(), bid.UserID, "/bid/detail/" + bid.BidID, (int)NotificationType.Bid); } uow.Save(); uow.Dispose(); }
public ActionResult WriteProposal(QuestionDetailModel model) { UnitOfWork uow = new UnitOfWork(); model.QuestionDetail = uow.UserRepository.GetQuestionDetailById(model.ProblemId); if (!ModelState.IsValid) { ModelState.AddModelError("error", Resources.Resources.InvalidInfo); return(View(model)); } StudentProblemBid problem = new StudentProblemBid { BidID = Guid.NewGuid().ToString(), UserID = Session["UserId"].ToString(), ProblemID = model.ProblemId, CreationDate = DateTime.Now, Description = model.Response, Status = (int)BidStatus.Created, }; uow.StudentProblemBids.Insert(problem); uow.Save(); Common.AddNotification(Session["UserName"] + " sent you a proposal", "", Session["UserId"].ToString(), model.QuestionDetail.UserID, "/problem/proposal/" + problem.BidID, (int)NotificationType.Question); ModelState.AddModelError("success", Resources.Resources.MsgProposalSuccess); return(View(model)); }
public void UpdateClassStatus(string bidId, string status) { try { string message = ""; string userId = Session["UserId"].ToString(); string userName = Session["UserName"].ToString(); UnitOfWork uow = new UnitOfWork(); StudentProblemBid bid = uow.StudentProblemBids.GetByID(bidId); StudentProblem problem = uow.StudentProblems.GetByID(bid.ProblemID); Class classDetail = uow.Classes.Get(x => x.ProblemID == problem.ProblemID).FirstOrDefault(); if (status == "accept") { if (Common.UserHasCredits(problem.StudentID, (decimal)problem.HoursNeeded)) { bid.Status = (int)BidStatus.Accepted; classDetail.Status = (int)ClassStatus.OfferAccepted; Common.AddNotification("Your offer is accepted by " + userName, "", userId, problem.StudentID, "/problem/proposal/" + bid.BidID, (int)NotificationType.Class); message = "Your offer is accepted by "; int braincertClassId = 0; if (classDetail.Type == (int)SessionType.Live) { braincertClassId = Convert.ToInt32(BrainCert.CreateBrainCertClass(classDetail.Title, classDetail.ClassDate.ToString("MM/dd/yyyy HH:mm"), classDetail.StartTime, classDetail.EndTime, Convert.ToInt32(classDetail.Record), Convert.ToInt32(classDetail.TimeZone))); classDetail.BrainCertId = braincertClassId; } DeductStudentCredits(problem.StudentID, classDetail.ClassID, (decimal)classDetail.Duration); } else { ModelState.AddModelError("error", Resources.Resources.MsgNoBalance); } } else if (status == "decline") { bid.Status = (int)BidStatus.Declined; classDetail.Status = (int)ClassStatus.OfferDeclined; Common.AddNotification("Your offer is declined by " + userName, "", userId, problem.StudentID, "/problem/proposal/" + bid.BidID, (int)NotificationType.Class); message = "Your offer is declined by "; } Message msg = new Message { BidID = bid.BidID, FromUser = userId, ToUser = bid.UserID, CreationDate = DateTime.Now, Message1 = message + userName, Status = 1, }; uow.Messages.Insert(msg); uow.Save(); uow.Dispose(); } catch (Exception ex) { } }
public ActionResult Problem(ProblemDetailModel model) { UnitOfWork uow = new UnitOfWork(); if (!ModelState.IsValid) { model.ProblemDetails = uow.UserRepository.GetQuestionDetailById(model.ProblemId); return(View(model)); } StudentProblemBid problem = new StudentProblemBid { BidID = Guid.NewGuid().ToString(), UserID = Session["UserId"].ToString(), ProblemID = model.ProblemId, CreationDate = DateTime.Now, Description = model.Response, Status = 1, }; uow.StudentProblemBids.Insert(problem); uow.Save(); return(RedirectToAction("problem", "student", new { problem = model.ProblemId })); }