public ActionResult Detail(string id, string accept, string decline) { if (id != null) { if (!string.IsNullOrEmpty(accept)) { UpdateClassStatus(id, "accept"); } else if (!string.IsNullOrEmpty(decline)) { UpdateClassStatus(id, "decline"); } UnitOfWork uow = new UnitOfWork(); BidDetailModel model = new BidDetailModel(); string userId = Session["UserId"].ToString(); StudentProblemDetailModel probDetail = uow.UserRepository.GetProblemDetailByBidId(id, userId); if (probDetail != null) { model.ProblemDetail = probDetail; model.Messages = uow.UserRepository.GetMessagesByBidId(id); model.BidId = id; } else { ViewBag.Msg = "No Data Is Available"; } return(View(model)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult BidResponse(BidDetailModel model) { if (!ModelState.IsValid) { return(RedirectToAction("detail", "bid", new { id = model.BidId })); } string userId = Session["UserId"].ToString(); UnitOfWork uow = new UnitOfWork(); model.ProblemDetail = uow.UserRepository.GetProblemDetailByBidId(model.BidId, userId); model.Messages = uow.UserRepository.GetMessagesByBidId(model.BidId); string toUser = "", fromUser = userId; if (userId == model.ProblemDetail.StudentID) { toUser = model.ProblemDetail.TeacherID; fromUser = model.ProblemDetail.StudentID; } else { toUser = model.ProblemDetail.StudentID; fromUser = model.ProblemDetail.TeacherID; } string fileHTML = SaveFiles(model.Files, userId, model.ProblemDetail.ProblemID); Message msg = new Message { BidID = model.BidId, FromUser = fromUser, ToUser = toUser, CreationDate = DateTime.Now, Message1 = model.Response + fileHTML, Status = 1, }; uow.Messages.Insert(msg); uow.Save(); //send messge notification Common.AddNotification(Session["UserName"].ToString() + " sent you a message", "", fromUser, toUser, "/problem/proposal/" + model.BidId, (int)NotificationType.Message); return(RedirectToAction("detail", "bid", new { id = model.BidId })); }