public async Task <IActionResult> Create([FromBody] FailureModeViewModel fmvm)
 {
     try
     {
         CurrentUser cUser = new CurrentUser(HttpContext, _configuration);
         fmvm.UserId        = cUser.UserId;
         fmvm.FailureModeId = 0;
         fmvm.Active        = "Y";
         return(Ok(await failureModeRepo.SaveOrUpdate(fmvm)));
     }
     catch (CustomException cex)
     {
         var returnObj = new EmaintenanceMessage(cex.Message, cex.Type, cex.IsException, cex.Exception?.ToString());
         return(StatusCode(StatusCodes.Status500InternalServerError, returnObj));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, new EmaintenanceMessage(ex.Message)));
     }
 }
        public async Task <IEnumerable <dynamic> > SaveOrUpdate([FromBody] FailureModeViewModel fmvm)
        {
            string sql = "dbo.EAppSaveFailureMode";

            using (var conn = util.MasterCon())
            {
                try
                {
                    return(await(conn.QueryAsync <dynamic>(sql, new
                    {
                        fmvm.FailureModeId,
                        fmvm.LanguageId,
                        fmvm.FailureModeCode,
                        fmvm.FailureModeName,
                        fmvm.Descriptions,
                        fmvm.Active,
                        fmvm.UserId
                    }, commandType: CommandType.StoredProcedure)));
                }
                catch (SqlException sqlException)
                {
                    if (sqlException.Number == 2601 || sqlException.Number == 2627)
                    {
                        throw new CustomException("Duplicate", "Failure Mode Code already Exists.", "Error", true, sqlException);
                    }
                    else
                    {
                        throw new CustomException("Due to some Technical Reason, Unable to Save or Update", "Error", true, sqlException);
                    }
                }
                catch (Exception ex)
                {
                    throw new CustomException("Unable to Save Or Update, Please Contact Support!!!", "Error", true, ex);
                }
            }
        }