public async Task <object> MapRoleUser(int userid, int roleID) { var item = await _repoRoleUser.FindAll().FirstOrDefaultAsync(x => x.UserID == userid); if (item == null) { _repoRoleUser.Add(new RoleUser { UserID = userid, RoleID = roleID, Status = true }); try { await _repoRoleUser.SaveAll(); return(new { status = true, message = "Mapping Successfully!" }); } catch (Exception) { return(new { status = false, message = "Failed on save!" }); } } else { item.UserID = userid; item.RoleID = roleID; try { await _repoRoleUser.SaveAll(); return(new { status = true, message = "Mapping Successfully!" }); } catch (Exception) { return(new { status = false, message = "Failed on save!" }); } } }