public IActionResult CreateRole(TblEmployeeRole model) { try { return(Ok(ep.CreateNewRole(model))); } catch (Exception ex) { Exceptions(ex); return(StatusCode(500)); } }
public int CreateNewRole(TblEmployeeRole model) { try { return(employee.CreateRole(model)); } catch (Exception ex) { StaticHelper.LogException(path: up.GetLogFilePath(), errorMessage: ex.Message, methodName: $"Class Name: {nameof(EmployeePresenter)} - Method name: {nameof(CreateNewRole)}", stackTrace: ex.StackTrace); return(0); } }
public int CreateRole(TblEmployeeRole model) { try { var IsEmployeeRoleExists = dbContext.TblEmployeeRole.Where(x => x.Role == model.Role).FirstOrDefault(); if (IsEmployeeRoleExists != null) { return(0); } else { dbContext.Add(model); return(dbContext.SaveChanges()); } } catch (Exception ex) { StaticHelper.LogException(path: up.GetLogFilePath(), errorMessage: ex.Message, methodName: $"Repository name: {nameof(EmployeeRepository)} - Method name: {nameof(CreateRole)}", stackTrace: ex.StackTrace); return(0); } }