PERMWebSolution.Models.TolerancesTolerancesModel.SaveNewTolerance C# (CSharp) Method

SaveNewTolerance() public method

public SaveNewTolerance ( TolerancesTolerancesModel tol ) : bool
tol TolerancesTolerancesModel
return bool
        public bool SaveNewTolerance(TolerancesTolerancesModel tol)
        {
            string sql = "INSERT INTO [TOLERANCE] (MEASUREMENT_Id, PROJECT_RISK_Id, Name, Value) VALUES (@MEASUREMENT_Id, @PROJECT_RISK_Id, @Name, @Value)";
            var param = new Dictionary<string, object>();
            param.Clear();
            param.Add("@MEASUREMENT_Id", 1);
            param.Add("@PROJECT_RISK_Id", tol.RiskID);
            param.Add("@Name", tol.ToleranceName);
            param.Add("@Value", tol.ToleranceValue);

            var result = DBContext.ExecuteQueryTable(sql, param);

            if (result != null)
                return true;

            return false;
        }

Usage Example

 public IHttpActionResult SaveNewTolerance(TolerancesTolerancesModel tolerance)
 {
     IHttpActionResult ret = null;
     if (tolerance != null && tolerance.SaveNewTolerance(tolerance))
     {
         ret = Ok("Pavyko");
     }
     else
     {
         ret = Ok("Nepavyko!");
     }
     return ret;
 }