Commit 4809ff38 authored by Mustafa Karapınar's avatar Mustafa Karapınar
Browse files

Initial commit

parents
Admin 58kdp58@gmail.com
Şifre mk123123
Admin kullanıcıları onaylar,rol ve bölümlere atama yapar.
Başkanlar proje oluşturur ve kendi ekibine görev verir
Normal çalışanlar görevleri yaptıklarında işaretler
\ No newline at end of file
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net6.0/sirkettodo.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
\ No newline at end of file
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/sirkettodo.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/sirkettodo.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/sirkettodo.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
\ No newline at end of file
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
namespace sirkettodo.Data;
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
namespace sirkettodo.Data;
public class WeatherForecastService
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
{
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = startDate.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
}).ToArray());
}
}
@page "/teamcrud"
@inherits AdminTeamCrud
<div id="operation">
<select @onchange="e=> {OpenMenu(e);}">
<option Selected>İşlem Seç</option>
<option value="0">Takım Ekle</option>
<option value="1">Takım Güncelle</option>
@* <option value="2">Takım Sil</option>*@
</select>
<br/>
<input id="teamid" type="text" @bind="team_id" placeholder="Team ID"/>
<br/>
<input id="teamname" type="text" @bind="team_name" placeholder="Team Name"/>
<br/>
<input id="teamname1" type="text" @bind="team_name" placeholder="Team Name"/>
<input id="updatebutton" type="button" @onclick="UpdateTeam" Value="Update Team"/>
<input id="addbutton" type="button" @onclick="AddTeam" Value="Add Team"/>
<input id="deletebutton" type="button" @onclick="SearchTeam" Value="Delete Team"/>
</div>
@if (TeamTable is null)
{
<p><em>Loading... !</em></p>
}
else
{
<table class="TeamTable">
<thead>
<tr class="header" style="border:1px solid black">
<th >Team ID</th>
<th>Team Name</th>
</tr>
</thead>
<tbody>
@foreach (var razorteam in TeamTable)
{
<tr class="TeamRow">
<td>@razorteam.team_id</td>
<td>@razorteam.team_name</td>
</tr>
}
</tbody>
</table>
}
\ No newline at end of file
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System.Data.SqlClient;
using System.Data;
using sirkettodo.Pages.EntityFramework;
using static sirkettodo.Pages.UserData;
namespace sirkettodo.Pages.AdminPage
{
public class AdminTeamCrud:ComponentBase
{
public string team_id{get;set;}
public string team_name{get;set;}
public AdminUserConfirm UserConfirms;
public List<Team> TeamTable=new List<Team>();
[Inject]
public EntitySqlService service{get;set;}
[Inject]
IJSRuntime JSRuntime { get; set; }
protected override async Task OnInitializedAsync()
{
if(UserData.Data.UserEmailData != "NULL" && UserData.Data.UserPasswordData != "NULL" && UserData.Data.UserRoleData == 0)
{
TeamTable.Clear();
TeamTable=GetTeam();
StateHasChanged();
}
else
{
JSRuntime.InvokeVoidAsync("gologin");
}
}
public List<Team> GetTeam(){
TeamTable= service.GetAllTeams();
return TeamTable;
}
public void OpenMenu(ChangeEventArgs e)
{
string value=e.Value.ToString();
if(value=="0")
{
JSRuntime.InvokeVoidAsync("openaddteam");
Console.WriteLine(value);
}
else if(value=="1")
{
JSRuntime.InvokeVoidAsync("openupdateteam");
Console.WriteLine(value);
}
else if(value=="2")
{
JSRuntime.InvokeVoidAsync("opendeleteteam");
Console.WriteLine(value);
}
}
public void AddTeam()
{
Team team=new Team();
team.team_name=team_name;
service.InsertTeamsAsync(team);
team.team_id=TeamTable.Last().team_id+1;
TeamTable.Add(team);
}
public async void UpdateTeam()
{
Team team = await Task.Run(() => service.GetTeamAsync(Convert.ToInt32(team_id)));
team.team_name=team_name;
await service.UpdateTeamAsync(team);
await InvokeAsync(StateHasChanged);
}
public async void SearchTeam()
{
Team team = await Task.Run(() => service.GetTeamAsync(Convert.ToInt32(team_id)));
if(team!=null)
{
DeleteTeam(team);
TeamTable.Remove(team);
}
}
protected async void DeleteTeam(Team team)
{
await service.DeleteTeamAsync(team);
await InvokeAsync(StateHasChanged);
}
/* public static string database = @"workstation id=sirkettodo.mssql.somee.com;packet size=4096;user id=Ramiz058_SQLLogin_1;pwd=rs91p7j2w2;data source=sirkettodo.mssql.somee.com;persist security info=False;initial catalog=sirkettodo";
public static SqlConnection connection = new SqlConnection(database);
public static SqlCommand command = connection.CreateCommand();*/
/*public void UpdateTeam(){
if(team_name!="")
{
command.CommandText = "insert into team values ('"+team_name+"')";
connection.Open();
command.ExecuteNonQuery();
connection.Close();
team_id="";
team_name="";
TeamTable.Clear();
TeamTable=GetTeam();
}
}*/
/*public void AddTeam(){
if(team_name!="")
{
command.CommandText = "insert into team values ('"+team_name+"')";
connection.Open();
command.ExecuteNonQuery();
connection.Close();
team_name="";
TeamTable.Clear();
TeamTable=GetTeam();
}
}*/
/*public void DeleteTeam(){
if(team_id!="")
{
command.CommandText = "delete from team where team_id="+team_id+"";
connection.Open();
command.ExecuteNonQuery();
connection.Close();
team_id="";
TeamTable.Clear();
TeamTable=GetTeam();
}
}*/
/*public List<Team> GetTeam()
{
connection.Open();
string sql = "select *from team";
SqlDataAdapter DataAdapterTeamTable= new SqlDataAdapter (sql, connection);
SqlCommandBuilder CommandBuilder = new SqlCommandBuilder(DataAdapterTeamTable);
DataSet DataSetTeamTable = new DataSet();
try
{
DataAdapterTeamTable.Fill(DataSetTeamTable, "TeamTable");
//error+=DataSetTeamTable.Tables[0].Rows.Count.ToString();
for (int i = 0; i < DataSetTeamTable.Tables[0].Rows.Count; i++)
{
Team getTeam = new Team();
getTeam.team_id = Int32.Parse(DataSetTeamTable.Tables[0].Rows[i]["team_id"].ToString());
last_team_id=getTeam.team_id;
getTeam.team_name = DataSetTeamTable.Tables[0].Rows[i]["team_name"].ToString();
TeamTable.Add(getTeam);
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
connection.Close();
return TeamTable;
}*/
}
}
\ No newline at end of file
@page "/userconfirm"
@inherits AdminUserConfirm
@if (UserTable is null)
{
<p><em>Loading... !</em></p>
}
else
{
int j=0;
Boolean kontrol;
<table class="table">
<thead>
<tr class="header" style="border:1px solid black">
<th >User_id</th>
<th>Name</th>
<th>Lastname</th>
<th>Email</th>
<th>Password</th>
<th>Reg_Date</th>
<th>Role</th>
<th>Team</th>
<th>ConfirmStat</th>
</tr>
</thead>
<tbody>
@foreach(var razorrole1 in RoleTable){
@foreach(var item in UserTable)
{
@if(razorrole1.role_id==item.role_id){
string kolonid="kolon"+razorrole1.role_id.ToString()+"";
j++;
string trid=j.ToString();
<tr id="@j" class="@kolonid">
<td>@item.user_id</td>
<td>@item.name</td>
<td>@item.lastname</td>
<td>@item.email</td>
<td>@item.password</td>
<td>@item.register_date</td>
<td><select @onchange="e => {ChangeRole(e,item.user_id,trid);}">
<option selected value=@item.role_id>
@foreach (var razorrole in RoleTable)
{
@if(razorrole.role_id==item.role_id)
@razorrole.role_name
}
</option>
@foreach (var razorrole in RoleTable)
{
@if(razorrole.role_id!=item.role_id)
{
<option value=@razorrole.role_id>@razorrole.role_name</option>
}
}
</select></td>
<td><select @onchange="e=> {ChangeTeam(e,item.user_id);}">
<option selected value=@item.team_id>
@foreach (var razorteam in TeamTable)
{
@if(razorteam.team_id==item.team_id)
@razorteam.team_name
}
</option>
@foreach (var razorteam in TeamTable)
{
@if(razorteam.team_id!=item.team_id)
{
<option value=@razorteam.team_id>@razorteam.team_name</option>
}
}
</select></td>
@if(@item.confirmation_status==0)
{
kontrol=false;
}
else
{
kontrol=true;
}
<td><input type="checkbox" @onchange="eventArgs => { ChangeConfirmation(item.email, eventArgs.Value); }" checked="@kontrol" /></td>
</tr>
}
}
}
</tbody>
</table>
}
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System.Data.SqlClient;
using System.Data;
using System.ComponentModel.DataAnnotations;
using sirkettodo.Pages.EntityFramework;
using static sirkettodo.Pages.UserData;
namespace sirkettodo.Pages.AdminPage
{
/*public class Users{
[Key]
public int user_id {get;set;}
public string name {get;set;}
public string lastname {get;set;}
public string email {get;set;}
public string password {get;set;}
public string register_date {get;set;}
public string role_id {get;set;}
public string team_id {get;set;}
public bool confirmation_status {get;set;}
}*/
/*public class Role{
[Key]
public int role_id {get;set;}
public string role_name {get;set;}
}*/
/*public class Team{
[Key]
public int team_id {get;set;}
public string team_name {get;set;}
}*/
public class AdminUserConfirm:ComponentBase
{
public static string database = @"workstation id=sirkettodo.mssql.somee.com;packet size=4096;user id=Ramiz058_SQLLogin_1;pwd=rs91p7j2w2;data source=sirkettodo.mssql.somee.com;persist security info=False;initial catalog=sirkettodo";
public static SqlConnection connection = new SqlConnection(database);
public static SqlCommand command = connection.CreateCommand();
public string name{get;set;}
public string lastname{get;set;}
public string email{get;set;}
public string password{get;set;}
public string callback{get;set;}="Default";
public string team_id{get;set;}
public string team_name{get;set;}
//public List<Users> UserTable=new List<Users>();
public List<Role> RoleTable=new List<Role>();
public List<Team> TeamTable=new List<Team>();
public List<UsersData> UserTable { get; set; }
[Inject]
public EntitySqlService service{get;set;}
[Inject]
public NavigationManager NavigationManager { get; set; }
[Inject]
IJSRuntime JSRuntime { get; set; }
protected override async Task OnInitializedAsync()
{
//RoleTable=GetRole();
//TeamTable=GetTeam();
//UserTable=GetUser();
//UserTable = await Task.Run(() =>service.GettAllUsers());
if(UserData.Data.UserEmailData != "NULL" && UserData.Data.UserPasswordData != "NULL" && UserData.Data.UserRoleData == 0)
{
TeamTable = await Task.Run(() =>GetTeam());
RoleTable = await Task.Run(() =>GetRole());
UserTable = await Task.Run(() =>GetUser());
StateHasChanged();
}
else
{
JSRuntime.InvokeVoidAsync("gologin");
}
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
string useremail=await JSRuntime.InvokeAsync<string>("useremail");
string userpassword=await JSRuntime.InvokeAsync<string>("userpassword");
string userrole=await JSRuntime.InvokeAsync<string>("userrole");
Console.WriteLine(useremail+" "+userpassword+" "+userrole);
}
}
public async Task<List<UsersData>> GetUser(){
UserTable = await Task.Run(() =>service.GetAllUsers());
return UserTable;
}
public async Task<List<Role>> GetRole(){
RoleTable = await Task.Run(() =>service.GetAllRoles());
return RoleTable;
}
public async Task<List<Team>> GetTeam(){
TeamTable = await Task.Run(() =>service.GetAllTeams());
return TeamTable;
}
public void ChangeRole(ChangeEventArgs e,int? user_id,string elementid)
{
string role_id = e.Value.ToString();
command.CommandText ="update users set role_id="+role_id+" where user_id="+user_id+"";
Console.WriteLine(command.CommandText);
connection.Open();
command.ExecuteNonQuery();
connection.Close();
JSRuntime.InvokeVoidAsync("ChangeColor",elementid,role_id);
StateHasChanged();
}
public void ChangeTeam(ChangeEventArgs e,int? user_id)
{
string team_id = e.Value.ToString();
command.CommandText ="update users set team_id="+team_id+" where user_id="+user_id+"";
Console.WriteLine(command.CommandText);
connection.Open();
command.ExecuteNonQuery();
connection.Close();
StateHasChanged();
//InvokeAsync(StateHasChanged);
}
public async void ChangeConfirmation(string UserEmail, object checkedValue)
{
bool newIsDone=(bool)checkedValue?true:false;
Console.WriteLine(newIsDone);
foreach(UsersData user in UserTable){
if(user.email == UserEmail){
if (newIsDone==true)
{
user.confirmation_status = 1;
}
else
{
user.confirmation_status = 0;
}
await UpdateUsers(user);
break;
}
}
}
protected async Task UpdateUsers(UsersData user)
{
await service.UpdateUsersAsync(user);
}
protected void UpdateUsers1(UsersData user)
{
service.UpdateUsersAsync1(user);
}
/*public List<Team> GetTeam()
{
connection.Open();
string sql = "select *from team";
SqlDataAdapter DataAdapterTeamTable= new SqlDataAdapter (sql, connection);
SqlCommandBuilder CommandBuilder = new SqlCommandBuilder(DataAdapterTeamTable);
DataSet DataSetTeamTable = new DataSet();
try
{
DataAdapterTeamTable.Fill(DataSetTeamTable, "TeamTable");
//error+=DataSetTeamTable.Tables[0].Rows.Count.ToString();
for (int i = 0; i < DataSetTeamTable.Tables[0].Rows.Count; i++)
{
Team getTeam = new Team();
getTeam.team_id = Int32.Parse(DataSetTeamTable.Tables[0].Rows[i]["team_id"].ToString());
getTeam.team_name = DataSetTeamTable.Tables[0].Rows[i]["team_name"].ToString();
TeamTable.Add(getTeam);
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
connection.Close();
return TeamTable;
}*/
/*public List<Role> GetRole()
{
connection.Open();
string sql = "select *from role";
SqlDataAdapter DataAdapterRoleTable= new SqlDataAdapter (sql, connection);
SqlCommandBuilder CommandBuilder = new SqlCommandBuilder(DataAdapterRoleTable);
DataSet DataSetRoleTable = new DataSet();
try
{
DataAdapterRoleTable.Fill(DataSetRoleTable, "RoleTable");
//error+=DataSetRoleTable.Tables[0].Rows.Count.ToString();
for (int i = 0; i < DataSetRoleTable.Tables[0].Rows.Count; i++)
{
Role getRole = new Role();
getRole.role_id = Int32.Parse(DataSetRoleTable.Tables[0].Rows[i]["role_id"].ToString());
getRole.role_name = DataSetRoleTable.Tables[0].Rows[i]["role_name"].ToString();
RoleTable.Add(getRole);
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
connection.Close();
return RoleTable;
}*/
/*public List<Users> GetUser()
{
connection.Open();
string sql = "select *from users";
SqlDataAdapter DataAdapterUserTable= new SqlDataAdapter (sql, connection);
SqlCommandBuilder CommandBuilder = new SqlCommandBuilder(DataAdapterUserTable);
DataSet DataSetUserTable = new DataSet();
try
{
DataAdapterUserTable.Fill(DataSetUserTable, "UserTable");
//error+=DataSetUserTable.Tables[0].Rows.Count.ToString();
for (int i = 0; i < DataSetUserTable.Tables[0].Rows.Count; i++)
{
Users getUser = new Users();
getUser.user_id = Int32.Parse(DataSetUserTable.Tables[0].Rows[i]["user_id"].ToString());
getUser.name = DataSetUserTable.Tables[0].Rows[i]["name"].ToString();
getUser.lastname = DataSetUserTable.Tables[0].Rows[i]["lastname"].ToString();
getUser.email = DataSetUserTable.Tables[0].Rows[i]["email"].ToString();
getUser.password = DataSetUserTable.Tables[0].Rows[i]["password"].ToString();
getUser.register_date = DataSetUserTable.Tables[0].Rows[i]["register_date"].ToString();
getUser.role_id = DataSetUserTable.Tables[0].Rows[i]["role_id"].ToString();
getUser.team_id = DataSetUserTable.Tables[0].Rows[i]["team_id"].ToString();
string cstat =DataSetUserTable.Tables[0].Rows[i]["confirmation_status"].ToString();
if(cstat=="1") getUser.confirmation_status = true;
else getUser.confirmation_status = false;
UserTable.Add(getUser);
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
connection.Close();
return UserTable;
}*/
/*public async void ChangeConfirmation(string UserEmail, object checkedValue)
{
bool newIsDone=(bool)checkedValue?true:false;
Console.WriteLine(newIsDone);
foreach(UsersData User in UserTable){
if(User.email == UserEmail){
if (newIsDone==true)
{
User.confirmation_status = 1;
command.CommandText = "update users set confirmation_status=1 where email='"+UserEmail+"'";
}
else
{
User.confirmation_status = 0;
command.CommandText = "update users set confirmation_status=0 where email='"+UserEmail+"'";
}
connection.Open();
command.ExecuteNonQuery();
connection.Close();
break;
}
}
}*/
/*public void ChangeRole(ChangeEventArgs e,int user_id,string elementid)
{
string role_id = e.Value.ToString();
string selectclass=role_id;
foreach(UsersData user in UserTable){
if(user.user_id == user_id){
user.role_id=Int32.Parse(role_id);
UpdateUsers1(user);
JSRuntime.InvokeVoidAsync("ChangeColor",elementid,selectclass);
break;
}
}
}*/
}
}
\ No newline at end of file
@page "/counter"
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace sirkettodo.Pages.EntityFramework
{
public class MyConnection : DbContext
{
public MyConnection(DbContextOptions<MyConnection> options) : base(options)
{
}
public DbSet<Projects> projects { get; set; }
public DbSet<UsersData> users { get; set; }
public DbSet<Tasks> tasks { get; set; }
public DbSet<Team> team { get; set; }
public DbSet<Role> role { get; set; }
public DbSet<TaskAssignment> task_assignment { get; set; }
}
}
\ No newline at end of file
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.SqlServer;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Net.Http;
using Microsoft.Data.SqlClient;
using sirkettodo.Pages.EntityFramework;
namespace sirkettodo.Pages.EntityFramework
{
public class EntitySqlService
{
private readonly MyConnection _appDBContext;
public EntitySqlService(MyConnection appDBContext)
{
_appDBContext = appDBContext;
}
public async Task<List<Projects>> GetAllProjects()
{
return await _appDBContext.projects.ToListAsync();
}
public async Task<bool> InserProjectsAsync(Projects project)
{
_appDBContext.projects.Add(project);//await _appDBContext.todos.AddAsync(todo);
await _appDBContext.SaveChangesAsync();
return true;
}
public async Task<bool> UpdateProjectAsync(Projects project)
{
_appDBContext.projects.Update(project);
await _appDBContext.SaveChangesAsync();
return true;
}
public async Task<List<UsersData>> GetAllUsers()
{
return await _appDBContext.users.ToListAsync();
}
public async Task<List<Tasks>> GetAllTasks()
{
return await _appDBContext.tasks.ToListAsync();
}
public async Task<bool> InsertTasksAsync(Tasks task)
{
_appDBContext.tasks.Add(task);//await _appDBContext.todos.AddAsync(todo);
await _appDBContext.SaveChangesAsync();
return true;
}
public async Task<bool> UpdateTasksAsync(Tasks task)
{
_appDBContext.tasks.Update(task);
await _appDBContext.SaveChangesAsync();
return true;
}
public async Task<bool> InsertTaskAssignmentAsync(TaskAssignment taskassign)
{
_appDBContext.task_assignment.Add(taskassign);
await _appDBContext.SaveChangesAsync();
return true;
}
public async Task<bool> UpdateTaskAssignmentAsync(TaskAssignment taskassign)
{
_appDBContext.task_assignment.Update(taskassign);
await _appDBContext.SaveChangesAsync();
return true;
}
public async Task<bool> UpdateUsersAsync(UsersData user)
{
_appDBContext.users.Update(user);
await _appDBContext.SaveChangesAsync();
return true;
}
public void UpdateUsersAsync1(UsersData user)
{
_appDBContext.users.Update(user);
_appDBContext.SaveChangesAsync();
}
public List<Role> GetAllRoles()
{
return _appDBContext.role.ToList();
}
public List<Team> GetAllTeams()
{
return _appDBContext.team.ToList();
}
public async Task<Team> GetTeamAsync(int Id)
{
Team team = await _appDBContext.team.FirstOrDefaultAsync(c => c.team_id.Equals(Id));
return team;
}
public async Task<bool> InsertTeamsAsync(Team team)
{
_appDBContext.team.Add(team);//await _appDBContext.todos.AddAsync(todo);
await _appDBContext.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteTeamAsync(Team team)
{
_appDBContext.Remove(team);
await _appDBContext.SaveChangesAsync();
return true;
}
public async Task<bool> UpdateTeamAsync(Team team)
{
_appDBContext.team.Update(team);
await _appDBContext.SaveChangesAsync();
return true;
}
public async Task<List<TaskAssignment>> GetAllMissions()
{
return await _appDBContext.task_assignment.ToListAsync();
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using sirkettodo.Pages.EntityFramework;
namespace sirkettodo.Pages.EntityFramework
{
public class Projects
{ [Key]
public int project_id { get; set; }
public string project_name { get; set; }
public string project_contents { get; set; }
public int team_id { get; set; }
public int project_status { get; set; }
public string starting_date { get; set; }
public string end_date { get; set;}
}
public class UsersData{
[Key]
public int user_id {get;set;}
public string name {get;set;}
public string lastname {get;set;}
public string email {get;set;}
public string password {get;set;}
public string register_date {get;set;}
public int role_id {get;set;}
public int team_id {get;set;}
public int confirmation_status {get;set;}
}
public class Tasks{
[Key]
public int task_id {get;set;}
public int project_id {get;set;}
public int tasks_status{get;set;}
public int team_id { get; set; }
public string task {get;set;}
}
public class Team{
[Key]
public int team_id {get;set;}
public string team_name {get;set;}
}
public class Role{
[Key]
public int role_id {get;set;}
public string role_name {get;set;}
}
public class TaskAssignment{
[Key]
public int task_assignment_id {get;set;}
public int team_id {get;set;}
public int task_id {get;set;}
public int mission_status {get;set;}
public int user_id {get;set;}
}
}
\ No newline at end of file
@page
@model sirkettodo.Pages.ErrorModel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Error</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true" />
</head>
<body>
<div class="main">
<div class="content px-4">
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
</div>
</div>
</body>
</html>
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace sirkettodo.Pages;
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
private readonly ILogger<ErrorModel> _logger;
public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
@page "/fetchdata"
<PageTitle>Weather forecast</PageTitle>
@using sirkettodo.Data
@inject WeatherForecastService ForecastService
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from a service.</p>
@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
@code {
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
}
}
@page "/assigntask"
@inherits AssignTaskCs
@using static sirkettodo.Pages.UserData
<p>@ResultMessage</p>
<br/>
<div id="navbutton">
<input type="button" value="Görev Ekle" @onclick="OpenAddTasks"/>
<input type="button" value="Görev Ata" @onclick="OpenAssignTask"/>
</div>
<div id="addtask">
<select @onchange="e => { SetProjectID(e); }">
@if(projects is null)
{
<p>Loading..</p>
}
else
{
<option selected value="-1">Proje Seçiniz</option>
@foreach (var razorproject in projects)
{
<option value=@razorproject.project_id>@razorproject.project_name</option>
}
}
</select><br/>
<label>Görev</label><br/>
<textarea id="pctextarea" @bind="task_contents" @bind:event="oninput"></textarea>
<br/>
<input type="button" value="Görev Ekle" @onclick="AddTasks"/>
</div>
<div id="assigntask" @onchange="e => { SetTaskID(e); }">
<select @onchange="e => { SetProjectID(e); }">
@if(projects is null)
{
<p>Loading..</p>
}
else
{
<option selected value="-1">Proje Seçiniz</option>
@foreach (var razorproject in projects)
{
<option value=@razorproject.project_id>@razorproject.project_name</option>
}
}
</select>
@if(TasksTableTemp is null)
{
<p>Loading...</p>
}
else
{
Boolean kontrol;
<table id="tasksselect" class="table">
<thead>
<tr class="header" style="border:1px solid black">
<th>Seç</th>
<th>Görev</th>
</tr>
</thead>
<tbody>
@foreach(var razortasks in TasksTableTemp)
{
string taskidstr=@razortasks.task_id.ToString();
<tr>
@if(@razortasks.tasks_status==0)
{
kontrol=false;
}
else
{
kontrol=true;
}
<td><input type="checkbox" @onchange="eventArgs => { GetTaskID(taskidstr,eventArgs.Value); }" checked="@kontrol" /></td>
<td>@razortasks.task</td>
</tr>
}
</tbody>
</table>
}
@*<select id="taskselect">
@if(TasksTableTemp is null)
{
<p>Loading...</p>
}
else
{
@foreach(var razortasks in TasksTableTemp)
{
<option value="-1" selected>Görev Seçin</option>
@if(razortasks.team_id==Data.UserTeamData)
{
Console.WriteLine("f");
<option value=@razortasks.task_id>@razortasks.task</option>
}
}
}
</select>*@
<select id="userselect" @ref=RefMulSelect @onchange=ChangedMulSelect multiple="@(true)" >
@if(UserTable is null)
{
<p>Loading...</p>
}
else{
@foreach(var razoruser in UserTable)
{
@if(razoruser.team_id==UserData.Data.UserTeamData && razoruser.user_id!=UserData.Data.UserIDData)
{
string namelastname=@razoruser.name+" "+@razoruser.lastname;
<option value=@razoruser.user_id>@namelastname</option>
}
}
}
</select>
<input type="button" value="Görev Ata" @onclick="AddTaskAssignment"/>
</div >
\ No newline at end of file
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components;
using System.Diagnostics;
using System.Globalization;
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using Microsoft.JSInterop;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Net.Http;
using System.Data.SqlClient;
using System.Data;
using sirkettodo.Pages.EntityFramework;
using static sirkettodo.Pages.UserData;
using System.Net.Mail;
namespace sirkettodo.Pages.LeaderPage
{
public class SelectUser{
public string user_id { get; set; }
}
public class AssignTaskCs:ComponentBase
{
public string projectid{ get; set; }="-1";
public string taskid{ get; set; }
public string task_contents{ get; set; }
public ElementReference RefMulSelect;
public List<Projects> projects { get; set; }
public List<Projects> ProjectsTable=new List<Projects>();
public List<UsersData> UserTable=new List<UsersData>();
public List<Tasks> TasksTable=new List<Tasks>();
public List<Tasks> TasksTableTemp=new List<Tasks>();
public List<TaskAssignment> TaskAssignmentTable=new List<TaskAssignment>();
public List<string> ChoosedMulItem { get; set; } = new List<string>();
[Inject]
public EntitySqlService service{get;set;}
[Inject]
public NavigationManager NavigationManager { get; set; }
[Inject]
IJSRuntime JSRuntime { get; set; }
protected override async Task OnInitializedAsync()
{
if(UserData.Data.UserEmailData != "NULL" && UserData.Data.UserPasswordData != "NULL" && UserData.Data.UserRoleData == 1)
{
ProjectsTable= await Task.Run(() =>service.GetAllProjects());
TasksTable= await Task.Run(() =>GetTasks());
UserTable = await Task.Run(() =>GetUser());
StateHasChanged();
}
else
{
JSRuntime.InvokeVoidAsync("gologin");
}
}
public async Task<List<UsersData>> GetUser(){
UserTable = await Task.Run(() =>service.GetAllUsers());
return UserTable;
}
public async Task<List<Tasks>> GetTasks(){
TasksTable = await Task.Run(() =>service.GetAllTasks());
return TasksTable;
}
public void SetProjectID(ChangeEventArgs e)
{
projectid = e.Value.ToString();
Console.WriteLine(projectid);
TasksTableTemp.Clear();
GetTasks(projectid);
InvokeAsync(StateHasChanged);
}
public void SetTaskID(ChangeEventArgs e)
{
taskid = e.Value.ToString();
Console.WriteLine(projectid);
InvokeAsync(StateHasChanged);
}
public List<Tasks> GetTasks(string prid)
{
foreach(var item in TasksTable)
{
if(item.project_id.ToString()==prid)
{
Console.WriteLine(item.task);
TasksTableTemp.Add(item);
}
}
return TasksTableTemp;
}
public async void AddTasks()
{
Tasks task=new Tasks();
task.task=task_contents;
task.project_id=Int32.Parse(projectid);
task.team_id=UserData.Data.UserTeamData;
task.tasks_status=0;
await service.InsertTasksAsync(task);
projectid="-1";
/*if(TasksTable == null)
{
task.task_id=1;
}
else
{
task.task_id=TasksTable.Last().task_id+1;
}*/
TasksTable.Add(task);
await OnInitializedAsync();
}
public async void AddTaskAssignment()
{
string projectname="";
string taskname="";
string useremail="";
Console.WriteLine("Addtaskssassignment selamm");
foreach(var item in ChoosedMulItem){
Console.WriteLine("sa");
TaskAssignment taskassign=new TaskAssignment();
taskassign.team_id=UserData.Data.UserTeamData;
taskassign.task_id=Int32.Parse(taskid);
taskassign.mission_status=0;
taskassign.user_id=Int32.Parse(item);
taskassign.mission_status=0;
await service.InsertTaskAssignmentAsync(taskassign);
TaskAssignmentTable.Add(taskassign);
foreach(var projectsname in projects)
{
if(projectsname.project_id.ToString()==projectid)
{
projectname=projectsname.project_name;
}
}
foreach(var taskg in TasksTableTemp)
{
if(taskg.task_id==Int32.Parse(taskid))
{
taskname=taskg.task;
}
}
foreach(var users in UserTable)
{
if(users.user_id==Int32.Parse(item))
{
useremail=users.email;
}
}
await SendMail(useremail,taskname,projectname);
await OnInitializedAsync();
}
/*if(TasksTable == null)
{
task.task_id=1;
}
else
{
task.task_id=TasksTable.Last().task_id+1;
}*/
}
public async void ChangedMulSelect()
{
ChoosedMulItem = await JSRuntime.InvokeAsync<List<string>>("mulselect", new object[] {RefMulSelect});
Console.WriteLine("Seçildi");
foreach(var item in ChoosedMulItem)
{
Console.WriteLine(item);
}
await InvokeAsync(StateHasChanged);
}
public async void GetTaskID(string gettaskid,object checkedValue)
{
bool newIsDone=(bool)checkedValue?true:false;
if (newIsDone==true)
{
taskid=gettaskid;
}
else
{
taskid="-1";
}
Console.WriteLine(taskid);
/*foreach(Tasks item in TasksTableTemp){
if(item.task_id == taskid){
if (newIsDone==true)
{
item.status = 1;
}
else
{
item.status = 0;
}
await UpdateTasks(item);
break;
}
}*/
}
public async void OpenAddTasks()
{
await JSRuntime.InvokeVoidAsync("OpenAddTasks");
}
public async void OpenAssignTask()
{
await JSRuntime.InvokeVoidAsync("OpenAssignTask");
}
public async Task UpdateTasks(Tasks user)
{
await service.UpdateTasksAsync(user);
}
/*public void ChangedMulSelect(ChangeEventArgs e)
{
SelectUser newuser=new SelectUser();
Boolean control=true;
newuser.user_id = e.Value.ToString();
Console.WriteLine(e.Value);
foreach(var user in ChoosedMulItem)
{
if(user.user_id==newuser.user_id)
{
control=false;
}
}
if(control==true)
{
ChoosedMulItem.Add(newuser);
}
else if(control==false)
{
ChoosedMulItem.Remove(newuser);
}
foreach(var user in ChoosedMulItem)
{
Console.WriteLine(user.user_id);
}
}*/
public string ResultMessage { get; set; } = "";
public async Task SendMail(string email,string task,string project)
{
try
{
using (MailMessage mail = new MailMessage()) {
mail.From = new MailAddress("ramiz058@hotmail.com");
mail.To.Add(email);
mail.Subject = project+" Projesi";
mail.Body =project+" projesi için '"+task+"' görevine dahil edildiniz";
mail.IsBodyHtml = true;
using (SmtpClient smtp = new SmtpClient("smtp.outlook.com", 587))
{
smtp.Credentials = new System.Net.NetworkCredential("ramiz058@hotmail.com", "tbmm200058");
smtp.EnableSsl =true;
smtp.Send(mail);
ResultMessage = "Mail Gitti";
}
}
}
catch(Exception e)
{
ResultMessage=e.Message;
}
}
}
}
@page "/createproject"
@inherits CreateProjectCs
<div id="title">
<label>Proje Adı</label>
<br/>
<label id="calendartitle">Bitiş Tarihi</label>
<br/>
<label>Proje İçeriği</label>
</div>
<div id="content">
<input type="text" @bind="project_name" /><br/>
<div id="calborder"><input id="calendar" type="date" @onchange="Sa" value="2022-12-30" style="border:none;"></div><br/>
<textarea id="pctextarea" @bind="project_contents" ></textarea>
</div>
<br/>
<input id="projectcreate" type="button" Value="Oluştur" @onclick="CreateProject">
<div>
<table class="table">
<thead>
<tr class="header" style="border:1px solid black">
<th >Proje ID</th>
<th>Adı</th>
<th>İçerik</th>
<th>Başlangıç</th>
<th>Bitiş</th>
<th>Durum</th>
</tr>
</thead>
<tbody>
@if(ProjectsTable is null)
{
<p>Loading..</p>
}
else
{
Boolean control;
@foreach(var razorproject in ProjectsTable){
<tr id="crprrow">
<td>@razorproject.project_id</td>
<td>@razorproject.project_name</td>
<td><textarea style="height:50px">@razorproject.project_contents</textarea></td>
<td>@razorproject.starting_date</td>
<td>@razorproject.end_date</td>
@if(@razorproject.project_status==0)
{
control=false;
}
else
{
control=true;
}
<td><input type="checkbox" @onchange="eventArgs => { ChangeProjectStat(razorproject.project_id, eventArgs.Value); }" checked="@control" /></td>
</tr>
}
}
</tbody>
</table>
</div>
@*<div>
<textarea @ref="edit" id="edit" ></textarea>
</div>
<br />
<button @onclick="getEdit">click</button>
<br />
<br />
<p>@editMessage</p>*@
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment