Пример #1
0
        public List <RiskItem> GetAllRisks()
        {
            List <RiskItem> risks = new List <RiskItem>();

            using (SqlConnection conn = new SqlConnection(_conn))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("procGetAllRisks", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    var reader = cmd.ExecuteReader();
                    while (reader.HasRows && reader.Read())
                    {
                        RiskItem Item = new RiskItem
                        {
                            RiskId     = Convert.ToInt32(reader["RiskId"]),
                            RiskName   = Convert.ToString(reader["RiskName"]),
                            AgentName  = Convert.ToString(reader["AgentName"]),
                            ActionName = Convert.ToString(reader["ActionName"]),
                        };
                        risks.Add(Item);
                    }
                }
                conn.Close();
            }
            return(risks);
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Description,RiskCategoryId,RiskClassId,Score")] RiskItem riskItem)
        {
            if (id != riskItem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(riskItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RiskItemExists(riskItem.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["RiskCategoryId"] = new SelectList(_context.Set <RiskCategory>(), "Id", "CategoryName");
            ViewData["RiskClassId"]    = new SelectList(_context.Set <RiskClass>(), "Id", "Classification");
            return(View(riskItem));
        }
        public async Task <RiskItemVM> GetRiskItem(Int32 Id, string user)
        {
            RiskItem riskItem = new RiskItem(_ampRepository);

            riskItem.ConstructRiskItem(Id);

            return(riskItem);
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("Id,Description,RiskCategoryId,RiskClassId,Score")] RiskItem riskItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(riskItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["RiskCategoryId"] = new SelectList(_context.Set <RiskCategory>(), "Id", "CategoryName");
            ViewData["RiskClassId"]    = new SelectList(_context.Set <RiskClass>(), "Id", "Classification");
            return(View(riskItem));
        }