fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6.  
  7. namespace MvcApplication6.Controllers
  8. {
  9. public class ContractsController : Controller
  10. {
  11. private MySqlEntities db = new MySqlEntities();
  12.  
  13. //
  14. // GET: /Contracts
  15.  
  16. public ActionResult Index()
  17. {
  18. return RedirectToAction("Inbox");
  19. }
  20.  
  21. //
  22. // GET: /Contracts/Indox
  23.  
  24. public ActionResult Inbox()
  25. {
  26. if (Request.Cookies["session-id"] == null)
  27. {
  28. Response.Redirect("/");
  29. return null;
  30. }
  31.  
  32. List<Models.ContractPlain> currentContracts = new List<Models.ContractPlain>();
  33.  
  34. try
  35. {
  36. var currentUserId = db.GetUserIdByLogin(Request.Cookies["user-name"].Value);
  37. int resultValue = Convert.ToInt32(currentUserId.FirstOrDefault());
  38.  
  39. foreach (var item in db.contracts)
  40. {
  41. if (item.recv_id == resultValue)
  42. {
  43. var record = new Models.ContractPlain
  44. {
  45. Id = item.id,
  46. ContractGuid = Guid.Parse(item.guid),
  47. SenderId = Convert.ToInt32(item.sender_id),
  48. RecvId = Convert.ToInt32(item.recv_id),
  49. ContractType = Convert.ToInt32(item.type),
  50. ContractStatus = item.status,
  51. CreatedTime = DateTime.Parse(item.date_created),
  52. CreditEnd = DateTime.Parse(item.date_credit_end)
  53. };
  54.  
  55. currentContracts.Add(record);
  56. }
  57. }
  58. }
  59. catch (Exception exc)
  60. {
  61. exc.ToString();
  62. }
  63.  
  64. return View(currentContracts);
  65. }
  66. }
  67. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty