daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [HttpPost]
  2. public IActionResult Create(CreateIntRecommendationVM createIntRecommendationVM)
  3. {
  4.     int findingId = createIntRecommendationVM.Finding.FindingId;
  5.         Finding finding = _findingRepo.Findings
  6.             .Include(f => f.Audit)
  7.             .Where(f => f.FindingId == findingId)
  8.             .FirstOrDefault();
  9.  
  10.     if (RecModelStateIsValid(ModelState))
  11.         {
  12.             ClaimsPrincipal user = HttpContext.Request.HttpContext.User;
  13.             short staffId = short.Parse(user.Claims.Single(c => c.Type == "StaffId").Value);
  14.  
  15.             Recommendation recommendation = createIntRecommendationVM.Recommendation;
  16.             recommendation.RecFindingId = findingId;
  17.  
  18.             #region Get Recommendation Number
  19.             recommendation.RecCd = GetRecommendationNumber(findingId);
  20.             #endregion
  21.  
  22.             recommendation.RecStatusId = 10;
  23.             recommendation.RecStaffId = staffId;
  24.             recommendation.RecLastUpdateDt = DateTime.Now;
  25.  
  26.             _recommendationRepo.Add(recommendation);
  27.             _recommendationRepo.SaveChanges();
  28.  
  29.             bool unresolvedFinding = false;
  30.             bool unresolvedAudit = false;
  31.             int? oldFindingStatus = finding.FindingStatusId;
  32.             if (finding.FindingStatusId != 10)
  33.             {
  34.                 finding.FindingStatusId = 10;
  35.                 unresolvedFinding = true;
  36.             }
  37.             if (oldFindingStatus != 10 && finding.Audit.StatusID != 10)
  38.             {
  39.                 finding.Audit.StatusID = 10;
  40.                 unresolvedAudit = true;
  41.             }
  42.  
  43.             _findingRepo.Update(finding);
  44.             _findingRepo.SaveChanges();
  45.    
  46. _findingRepo.Update(finding);
  47.    
  48. public class FindingRepository : IFindingRepository
  49.     {
  50.         private ApplicationDbContext context;
  51.         public FindingRepository(ApplicationDbContext ctx)
  52.         {
  53.             context = ctx;
  54.         }
  55.  
  56.         public IQueryable<Finding> Findings => context.Findings;
  57.  
  58.         public Finding Get(int id)
  59.         {
  60.             Finding finding = context.Findings.Find(id);
  61.             return finding;
  62.         }
  63.  
  64.         public void Add(Finding finding)
  65.         {
  66.             context.Findings.Add(finding);
  67.         }
  68.  
  69.         public void Update(Finding finding)
  70.         {
  71.             context.Findings.Update(finding);
  72.         }
  73.  
  74.         public void Delete(int id)
  75.         {
  76.             context.Database.ExecuteSqlCommand("sp_delete_finding_int @finding_id = {0}", id);
  77.         }
  78.  
  79.         public void SaveChanges()
  80.         {
  81.             context.SaveChanges();
  82.         }
  83.     }
  84.    
  85. [Table("finding")]
  86.     public class Finding
  87.     {
  88.         private string _findingText;
  89.  
  90.         [Key]
  91.         [Column("finding_id")]
  92.         public int FindingId { get; set; }
  93.  
  94.         [Column("finding_audit_id")]
  95.         public int FindingAuditId { get; set; }
  96.  
  97.         [Column("finding_cd")]
  98.         [Display(Name = "Finding #")]
  99.         [StringLength(15)]
  100.         public string FindingCd { get; set; }
  101.  
  102.         [Column("finding_tx")]
  103.         [Required(ErrorMessage = "Description Required")]
  104.         [StringLength(7000)]
  105.         public string FindingText
  106.         {
  107.             get
  108.             {
  109.                 return _findingText;
  110.             }
  111.             set
  112.             {
  113.                 _findingText = value?.Trim();
  114.             }
  115.         }
  116.  
  117.         [Column("finding_page_cd")]
  118.         [StringLength(100)]
  119.         public string FindingPageCd { get; set; }
  120.  
  121.         [Column("finding_joint_cd")]
  122.         public string FindingJointCd { get; set; }
  123.  
  124.         [Column("finding_compliance_tx")]
  125.         [StringLength(20)]
  126.         public string FindingComplianceText { get; set; }
  127.  
  128.         [Column("finding_prior_year_cd")]
  129.         [Display(Name = "Repeat Finding")]
  130.         public string FindingPriorYearCd { get; set; }
  131.  
  132.         [Column("finding_decision_cd")]
  133.         public string FindingDecisionCd { get; set; }
  134.  
  135.         [Column("finding_request_decision_cd")]
  136.         public string FindingRequestDecisionCd { get; set; }
  137.  
  138.         [Column("finding_decision_ogc_concur_cd")]
  139.         public string FindingDecisionOgcConcurCd { get; set; }
  140.  
  141.         [Column("finding_pdl_id")]
  142.         public int? FindingPdlId { get; set; }
  143.  
  144.         [Display(Name = "Significant")]
  145.         [Column("finding_significant_cd")]
  146.         public string FindingSignificantCd { get; set; }
  147.  
  148.         [Column("finding_on_stay_cd")]
  149.         public string FindingOnStayCd { get; set; }
  150.  
  151.         [Column("finding_stay_request_cd")]
  152.         public string FindingStayRequestCd { get; set; }
  153.  
  154.         [Column("finding_last_update_dt")]
  155.         public DateTime FindingLastUpdateDate { get; set; }
  156.  
  157.         [Column("finding_update_staff_id")]
  158.         public short? FindingUpdateStaffId { get; set; }
  159.  
  160.         [Column("finding_cd_org")]
  161.         public string FindingCdOrg { get; set; }
  162.  
  163.         [NotMapped]
  164.         public string RepeatingYearsDisplayList
  165.         {
  166.             get
  167.             {
  168.                 if (RepeatingYears?.Count > 0)
  169.                 {
  170.                     string repeatingYears = string.Empty;
  171.                     RepeatingYears.ForEach(ry =>
  172.                         repeatingYears += $"{ry.FindingFyCd}, ");
  173.                     return repeatingYears.Remove(repeatingYears.Length - 2);
  174.                 }
  175.                 return string.Empty;
  176.             }
  177.         }
  178.  
  179.         #region Navigation Properties
  180.         [Column("finding_finding_type_id")]
  181.         public short? FindingTypeId { get; set; }
  182.         [ForeignKey("FindingTypeId")]
  183.         public FindingType FindingType { get; set; }
  184.  
  185.         [Column("finding_status_id")]
  186.         public int? FindingStatusId { get; set; }
  187.         [ForeignKey("FindingStatusId")]
  188.         public Status FindingStatus { get; set; }
  189.  
  190.         public List<FindingFiscalYear> RepeatingYears { get; set; }
  191.         public List<Recommendation> Recommendations { get; set; }
  192.  
  193.         [ForeignKey("FindingAuditId")]
  194.         public Audit Audit { get; set; }
  195.         #endregion
  196.     }
  197.  
  198.  
  199.  
  200. [Table("audit")]
  201.     public class Audit
  202.     {
  203.         private string _auditAcnCd;
  204.         private string _title;
  205.         private string _summary;
  206.  
  207.         [Key]
  208.         [Column("audit_id")]
  209.         public int AuditID { get; set; }
  210.  
  211.         [Required(ErrorMessage = "ACN Required")]
  212.         [Display(Name="ACN:")]
  213.         [Column("audit_acn_cd")]
  214.         public string AuditAcnCd
  215.         {
  216.             get
  217.             {
  218.                 return _auditAcnCd;
  219.             }
  220.             set
  221.             {
  222.                 _auditAcnCd = value?.Trim();
  223.             }
  224.         }
  225.  
  226.         [Required(ErrorMessage = "Title Required")]
  227.         [Display(Name = "Title:")]
  228.         [Column("audit_report_title_tx")]
  229.         public string Title
  230.         {
  231.             get
  232.             {
  233.                 return _title;
  234.             }
  235.             set
  236.             {
  237.                 _title = value?.Trim();
  238.             }
  239.         }
  240.  
  241.         [Required(ErrorMessage = "Issuer Required")]
  242.         [Display(Name="Issuer:")]
  243.         [Column("audit_issuer_tx")]
  244.         public string Issuer { get; set; }
  245.  
  246.         [Display(Name = "Sensitive Designation")]
  247.         [Column("audit_sensitive_cd")]
  248.         public string AuditSensitiveCode { get; set; }
  249.  
  250.         [Display(Name = "Alternative Product")]
  251.         [Column("audit_alternate_product_cd")]
  252.         public string AuditAlternateProductCode { get; set; }
  253.  
  254.         [RegularExpression("([1-9][0-9]*)", ErrorMessage = "Priority must be a number.")]
  255.         [Display(Name = "Priority:")]
  256.         [Column("audit_priority_cd")]
  257.         public short? Priority { get; set; }
  258.  
  259.         [StringLength(maximumLength: 1000,ErrorMessage = "Max Length: 1000")]
  260.         [Display(Name = "Summary:")]
  261.         [Column("audit_summary_tx")]
  262.         public string Summary
  263.         {
  264.             get
  265.             {
  266.                 return _summary;
  267.             }
  268.             set
  269.             {
  270.                 _summary = value?.Trim();
  271.             }
  272.         }
  273.  
  274.         [Column("audit_gao_contact_tx")]
  275.         [Display(Name = "GAO Contact:")]
  276.         [StringLength(maximumLength: 200, ErrorMessage = "Max Length: 200")]
  277.         public string AuditGaoContactText { get; set; }
  278.  
  279.         [Column("audit_gao_job_cd")]
  280.         [Display(Name = "GAO Job Code:")]
  281.         [StringLength(maximumLength: 200, ErrorMessage = "Max Length: 30")]
  282.         public string AuditGaoJobCode { get; set; }
  283.  
  284.         [Display(Name = "Lead Office:")]
  285.         [Column("audit_lead_office_id")]
  286.         public short? LeadOfficeID { get; set; }
  287.  
  288.         #region Navigation Properties
  289.         [Required(ErrorMessage = "Audit Type Required.")]
  290.         [Display(Name = "Audit Type:")]
  291.         [Column("audit_audit_type_id")]
  292.         public short AuditTypeID { get; set; }
  293.         [Display(Name = "Audit Type:")]
  294.         public AuditType AuditType { get; set; }
  295.  
  296.         [Column("audit_status_id")]
  297.         public int StatusID { get; set; }
  298.         public Status Status { get; set; }
  299.  
  300.         [Required(ErrorMessage = "Office is Required.")]
  301.         [Display(Name = "Offices:")]
  302.         [Column("audit_office_id")]
  303.         public short? OfficeID { get; set; }
  304.         public Office Office { get; set; }
  305.  
  306.         [ForeignKey("AuditID")]
  307.         public External External { get; set; }
  308.  
  309.         public IEnumerable<AuditLog> AuditLogs { get; set; }
  310.         public IEnumerable<Finding> Findings { get; set; }
  311.         public IEnumerable<Assignment> Assignments { get; set; }
  312.  
  313.         [Column("audit_update_staff_id")]
  314.         public short UpdateStaffID { get; set; }
  315.  
  316.         [Column("audit_oig_manager_id")]
  317.         [Display(Name = "OIG Audit Manager:")]
  318.         public short? OigAuditManagerId { get; set; }
  319.         [Display(Name = "OIG Audit Manager:")]
  320.         [ForeignKey("OigAuditManagerId")]
  321.         public Staff OigAuditManager { get; set; }
  322.  
  323.         [Column("audit_fsa_office_id")]
  324.         [Display(Name = "FSA Audit Lead:")]
  325.         public int? FsaLeadOfficeId { get; set; }
  326.         [Display(Name = "FSA Audit Lead:")]
  327.         [ForeignKey("FsaLeadOfficeId")]
  328.         public FSAOffice FsaLeadOffice { get; set; }
  329.  
  330.         [ForeignKey("LeadOfficeID")]
  331.         public Office LeadOffice { get; set; }
  332.         #endregion
  333.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top