public IActionResult Delete(string id) { TransExpenseModelOutput _expenseModel = new TransExpenseModelOutput(); try { _logger.Information("Delete Expense " + id); UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); ExpenseServices _expense = new ExpenseServices { objUser = usrSession.UserLog(userId)._userInfo }; var response = _expense.Delete(id); _expenseModel.IsSuccess = true; _expenseModel.Message = "Success Delete"; _expenseModel.Code = 200; } catch (Exception ex) { _logger.Error("delete Expense" + ex.Message); _expenseModel.IsSuccess = false; _expenseModel.Message = "Failed Delete" + ex.Message; _expenseModel.Code = 422; } return(Ok(_expenseModel)); }
public IActionResult DetailCategory(string id) { CategoryModelOutput categoryModel = new CategoryModelOutput(); try { _logger.Information("Delete Category " + id); UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); DisplayCategory displayCategory = new DisplayCategory { objUser = usrSession.UserLog(userId)._userInfo }; var collection = new List <CategoryModel>((List <CategoryModel>)displayCategory.DisplayDetailCategory(id)); categoryModel.IsSuccess = true; categoryModel.Message = "Success"; categoryModel.Code = 200; categoryModel.Data = collection; } catch (Exception ex) { _logger.Error("detail Category" + ex.Message); categoryModel.IsSuccess = false; categoryModel.Message = "Failed Delete" + ex.Message; categoryModel.Code = 422; } return(Ok(categoryModel)); }
public IActionResult Update([FromBody] TransExpenseModel model, string id) { TransExpenseModelOutput _expenseModel = new TransExpenseModelOutput(); try { if (ModelState.IsValid) { _logger.Information("update Post Expense"); UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); ExpenseServices _expense = new ExpenseServices { objUser = usrSession.UserLog(userId)._userInfo }; var response = _expense.Update(model, id); _expenseModel.IsSuccess = true; _expenseModel.Message = "Success Saving"; _expenseModel.Code = 200; } else { _logger.Error("update Expense"); string errordetails = ""; var errors = new List <string>(); foreach (var state in ModelState) { foreach (var error in state.Value.Errors) { string p = error.ErrorMessage; errordetails = errordetails + error.ErrorMessage; } } Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("error", errordetails); _expenseModel.IsSuccess = false; _expenseModel.Message = "error update saving validating"; _expenseModel.Code = 422; _expenseModel.CustomField = dict; } } catch (Exception ex) { _logger.Error("update Post Expense" + ex.Message); _expenseModel.IsSuccess = false; _expenseModel.Message = "Failed update" + " Saving" + ex.Message; _expenseModel.Code = 422; } return(Ok(_expenseModel)); }
public IActionResult Store([FromBody] CategoryModel model) { CategoryModelOutput categoryModel = new CategoryModelOutput(); try { if (ModelState.IsValid) { _logger.Information("Post Sub Category " + model.category_name); UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); CategoryServices categoryServices = new CategoryServices { objUser = usrSession.UserLog(userId)._userInfo }; model.category_parentid = model.category_parentid; var response = categoryServices.AddSubCategory(model); categoryModel.IsSuccess = true; categoryModel.Message = "Success Saving"; categoryModel.Code = 200; } else { _logger.Error("Post Sub Category " + model.category_name); string errordetails = ""; var errors = new List <string>(); foreach (var state in ModelState) { foreach (var error in state.Value.Errors) { string p = error.ErrorMessage; errordetails = errordetails + error.ErrorMessage; } } Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("error", errordetails); categoryModel.IsSuccess = false; categoryModel.Message = "error saving validating"; categoryModel.Code = 422; categoryModel.CustomField = dict; } } catch (Exception ex) { _logger.Error("Post Sub Category" + ex.Message); categoryModel.IsSuccess = false; categoryModel.Message = "Failed Saving" + ex.Message; categoryModel.Code = 422; } return(Ok(categoryModel)); }
public IActionResult Update([FromBody] UserModel request, string id) { UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); UserModelOutput userModelOutput = new UserModelOutput(); try { _logger.Information("Update User"); DisplayUser displayUser = new DisplayUser(); var query = new List <UserModel>((List <UserModel>)displayUser.DisplayAll()).AsQueryable(); if (ModelState.IsValid) { UserServices userServices = new UserServices { objUser = usrSession.UserLog(userId)._userInfo }; var res = userServices.Update(request, id); userModelOutput.IsSuccess = true; userModelOutput.Message = "Success Update"; userModelOutput.Code = 200; } else { _logger.Error("Error Post Account"); string errordetails = ""; var errors = new List <string>(); foreach (var state in ModelState) { foreach (var error in state.Value.Errors) { string p = error.ErrorMessage; errordetails = errordetails + error.ErrorMessage; } } Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("error", errordetails); userModelOutput.IsSuccess = false; userModelOutput.Message = "error Update validating"; userModelOutput.Code = 422; userModelOutput.CustomField = dict; } } catch (Exception ex) { _logger.Error(ex.Message.ToString()); userModelOutput.IsSuccess = false; userModelOutput.Message = "Failed Update" + ex.Message; userModelOutput.Code = 422; } return(Ok(userModelOutput)); }
public IActionResult Post([FromBody] AccountModel request) { UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); AccountModelOutput accountModelOutput = new AccountModelOutput(); try { _logger.Information("Saving Account"); if (ModelState.IsValid) { AccountServices accountServices = new AccountServices { objUser = usrSession.UserLog(userId)._userInfo }; var res = accountServices.Add(request); accountModelOutput.IsSuccess = true; accountModelOutput.Message = "Success Saving"; accountModelOutput.Code = 200; } else { _logger.Error("Error Post Account"); string errordetails = ""; var errors = new List <string>(); foreach (var state in ModelState) { foreach (var error in state.Value.Errors) { string p = error.ErrorMessage; errordetails = errordetails + error.ErrorMessage; } } Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("error", errordetails); accountModelOutput.IsSuccess = false; accountModelOutput.Message = "error saving validating"; accountModelOutput.Code = 422; accountModelOutput.CustomField = dict; } } catch (Exception ex) { _logger.Error(ex.Message.ToString()); accountModelOutput.IsSuccess = false; accountModelOutput.Message = "Failed Saving" + ex.Message; accountModelOutput.Code = 422; } return(Ok(accountModelOutput)); }
public IActionResult UpdateRolesUser(string rolesid) { try { _logger.Information("update Roles by user" + rolesid); UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); RolesServices rolesServices = new RolesServices { objUser = usrSession.UserLog(userId)._userInfo }; var query = rolesServices.UpdateRoles(rolesid); if (query.Result == 1) { var response = new RoleModelOutput { IsSuccess = true, Code = 200, Message = "Success Update", }; return(Ok(response)); } else { var response = new RoleModelOutput { IsSuccess = false, Code = 422, Message = "error update", }; return(Ok(response)); } } catch (Exception ex) { _logger.Error(ex.Message.ToString()); var response = new RoleModelOutput { IsSuccess = false, Code = 422, Message = ex.Message.ToString(), }; return(Ok(response)); } }
public IActionResult Index(PagingParams pagingParams) { try { _logger.Information("GetExpense"); UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); ExpenseServices _expense = new ExpenseServices { objUser = usrSession.UserLog(userId)._userInfo }; objResponse = _expense.GetAll(pagingParams); Response.Headers.Add("X-Pagination", objResponse.GetHeader().ToJson()); var response = new TransExpenseModelOutput { IsSuccess = true, Code = 200, Message = "Success Get Expense", Data = objResponse.List.Select(m => ExpenseInfo(m)).ToList(), Pagination = GetLinks(objResponse, "GetExpense") }; return(Ok(response)); } catch (Exception ex) { _logger.Error(ex.Message.ToString()); var response = new TransExpenseModelOutput { IsSuccess = false, Code = 422, Message = ex.Message.ToString(), }; return(Ok(response)); } }
public IActionResult RoleByUser(string userid) { try { _logger.Information("Get Roles by user" + userid); UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); DisplayRoles displayRoles = new DisplayRoles { objUser = usrSession.UserLog(userId)._userInfo }; var query = new List <RoleModel>((List <RoleModel>)displayRoles.Search(userid)).ToList(); var response = new RoleModelOutput { IsSuccess = true, Code = 200, Message = "Success", Data = query }; return(Ok(response)); } catch (Exception ex) { _logger.Error(ex.Message.ToString()); var response = new RoleModelOutput { IsSuccess = false, Code = 422, Message = ex.Message.ToString(), }; return(Ok(response)); } }
public IActionResult Post([FromBody] UserModel request) { UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); UserModelOutput userModelOutput = new UserModelOutput(); try { _logger.Information("Saving User"); DisplayUser displayUser = new DisplayUser(); var query = new List <UserModel>((List <UserModel>)displayUser.DisplayAll()).AsQueryable(); var CheckEmail = query.Where(p => p.user_email.StartsWith(request.user_email ?? String.Empty, StringComparison.InvariantCultureIgnoreCase)); if (CheckEmail.Count() > 0) { ModelState.AddModelError("Email", "Email already exists"); } if (ModelState.IsValid) { UserServices userServices = new UserServices { objUser = usrSession.UserLog(userId)._userInfo }; var res = userServices.Add(request); userModelOutput.IsSuccess = true; userModelOutput.Message = "Success Saving"; userModelOutput.Code = 200; } else { _logger.Error("Error Post Account"); string errordetails = ""; var errors = new List <string>(); foreach (var state in ModelState) { foreach (var error in state.Value.Errors) { string p = error.ErrorMessage; errordetails = errordetails + error.ErrorMessage; } } Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("error", errordetails); userModelOutput.IsSuccess = false; userModelOutput.Message = "error saving validating"; userModelOutput.Code = 422; userModelOutput.CustomField = dict; } } catch (Exception ex) { _logger.Error(ex.Message.ToString()); userModelOutput.IsSuccess = false; userModelOutput.Message = "Failed Saving" + ex.Message; userModelOutput.Code = 422; } return(Ok(userModelOutput)); }
public IActionResult IndexSubCategory(PagingParams pagingParams, string id = null, string parent = null) { try { _logger.Information("GetSubCategory"); UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); if (id == null) { CategoryServices categoryServices = new CategoryServices { objUser = usrSession.UserLog(userId)._userInfo }; objResponse = categoryServices.GetAllSubCategories(pagingParams, parent); Response.Headers.Add("X-Pagination", objResponse.GetHeader().ToJson()); var response = new CategoryModelOutput { IsSuccess = true, Code = 200, Message = "Success Get Category", Data = objResponse.List.Select(m => CategoryInfo(m)).ToList(), Pagination = GetLinks(objResponse, "GetSubCategory") }; return(Ok(response)); } else { DisplayCategory displayCategory = new DisplayCategory { objUser = usrSession.UserLog(userId)._userInfo }; var collection = new List <CategoryModel>((IEnumerable <CategoryModel>)displayCategory.DisplayDetailSubCategory(id)); var response = new CategoryModelOutput { IsSuccess = true, Code = 200, Message = "Success Get Category", Data = collection, }; return(Ok(response)); } } catch (Exception ex) { _logger.Error(ex.Message.ToString()); var response = new CategoryModelOutput { IsSuccess = false, Code = 422, Message = ex.Message.ToString(), }; return(Ok(response)); } }