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

Initial commit

parents
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;
namespace sirkettodo.Pages.LeaderPage
{
public class CreateProjectCs:ComponentBase
{
public DateTime tarih{get;set;}=DateTime.Now;
public string project_name{get;set;}
public string project_contents{get;set;}
public string starih{get;set;}
public List<Projects> projects { get; set; }
public List<Projects> ProjectsTable=new List<Projects>();
public List<Team> TeamTable=new List<Team>();
[Inject]
public EntitySqlService service{get;set;}
[Inject]
IJSRuntime JSRuntime{ get; set; }
public async Task Sa(ChangeEventArgs args)
{
tarih = DateTime.Parse(args.Value.ToString());
starih=tarih.ToString("dd/MM/yyyy");
}
protected override async Task OnInitializedAsync()
{
if(UserData.Data.UserEmailData != "NULL" && UserData.Data.UserPasswordData != "NULL" && UserData.Data.UserRoleData == 1)
{
TeamTable.Clear();
TeamTable=GetTeam();
ProjectsTable.Clear();
ProjectsTable = await Task.Run(() =>GetProject());
}
else
{
JSRuntime.InvokeVoidAsync("gologin");
}
/*projects.Clear();
projects= await Task.Run(() =>service.GetAllProjects());*/
/*if(projects == null)
{
Console.WriteLine("Bekleniyor");
}
else{
foreach(var p1 in projects)
{
Console.WriteLine(p1.project_id);
Console.WriteLine(p1.project_name);
Console.WriteLine(p1.project_contents);
Console.WriteLine(p1.end_date);
}
}*/
}
public List<Team> GetTeam()
{
TeamTable= service.GetAllTeams();
return TeamTable;
}
public async Task CreateProject()
{
Projects project=new Projects();
project.project_name=project_name;
project.project_contents=project_contents;
project.project_status=0;
project.team_id=UserData.Data.UserRoleData;
project.starting_date=DateTime.Now.ToString("dd/MM/yyyy");
project.end_date=starih;
await service.InserProjectsAsync(project);
ProjectsTable.Add(project);
await OnInitializedAsync();
}
public async Task<List<Projects>> GetProject(){
ProjectsTable = await Task.Run(() =>service.GetAllProjects());
return ProjectsTable;
}
public async void ChangeProjectStat(int ProjectID, object checkedValue)
{
bool newIsDone=(bool)checkedValue?true:false;
foreach(Projects project in ProjectsTable)
{
if(project.project_id == ProjectID)
{
if (newIsDone==true)
{
project.project_status = 1;
}
else
{
project.project_status = 0;
}
await UpdateProject(project);
break;
}
}
}
protected async Task UpdateProject(Projects project)
{
await service.UpdateProjectAsync(project);
}
}
}
\ No newline at end of file
@page "/login"
<br/>
<div id="login_elemanlari">
<input type="email" @bind="email" @bind:event="oninput" placeholder="Email" required><br/>
<input type="password" @bind="password" @bind:event="oninput" id="input2" placeholder="Şifre" maxlength="8" required><br/>
<input type="button" class="btn btn-warning" @onclick="LoginButton" value="Giriş Yap">
<p>@callback</p>
</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;
namespace sirkettodo.Pages
{
public partial class UserData {
public class Data {
public static string UserEmailData{ get; set; }="null";
public static string UserPasswordData{ get; set; }="null";
public static int UserRoleData{ get; set; }=-1;
public static int UserTeamData{ get; set; }=-1;
public static int UserIDData{ get; set; }=-1;
}
}
public partial class Login
{
public string email{get;set;}
public string password{get;set;}
public string callback{get;set;}="";
[Inject]
IJSRuntime JSRuntime { get; set; }
[Inject]
public NavigationManager NavigationManager { get; set; }
protected override async Task OnInitializedAsync()
{
if(UserData.Data.UserEmailData!="NULL")
{
JSRuntime.InvokeVoidAsync("gologin");
}
UserData.Data.UserEmailData="NULL";
UserData.Data.UserPasswordData="NULL";
UserData.Data.UserRoleData=-1;
UserData.Data.UserRoleData=-1;
UserData.Data.UserTeamData=-1;
}
public void LoginButton()
{
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";
SqlConnection connection = new SqlConnection(database);
SqlCommand command = connection.CreateCommand();
command.CommandText ="exec login'"+email+"','"+password+"',@callback OUTPUT,@callback_role_id OUTPUT,@callback_team_id OUTPUT,@callback_user_id OUTPUT";
SqlParameter callback_output = command.Parameters.Add("@callback", SqlDbType.Int);
SqlParameter callback_role_output = command.Parameters.Add("@callback_role_id", SqlDbType.Int);
SqlParameter callback_team_output = command.Parameters.Add("@callback_team_id", SqlDbType.Int);
SqlParameter callback_user_id_output = command.Parameters.Add("@callback_user_id", SqlDbType.Int);
callback_output.Direction = ParameterDirection.Output;
callback_role_output.Direction = ParameterDirection.Output;
callback_team_output.Direction = ParameterDirection.Output;
callback_user_id_output.Direction = ParameterDirection.Output;
connection.Open();
command.ExecuteNonQuery();
if(Int32.Parse(callback_output.Value.ToString())==1)
{
callback="Kullanıcı bilgileri yanlış.";
}
else if(Int32.Parse(callback_output.Value.ToString())==2)
{
callback="Bu kullanıcı onay bekliyor.";
}
else if(Int32.Parse(callback_output.Value.ToString())==3)
{
JSRuntime.InvokeVoidAsync("login",email,password,callback_role_output.Value.ToString(),callback_team_output.Value.ToString());
callback="Giriş Başarılı.";
UserData.Data.UserEmailData=email;
UserData.Data.UserPasswordData=password;
UserData.Data.UserRoleData=Int32.Parse(callback_role_output.Value.ToString());
UserData.Data.UserTeamData=Int32.Parse(callback_team_output.Value.ToString());
UserData.Data.UserIDData=Int32.Parse(callback_user_id_output.Value.ToString());
int role_id=Int32.Parse(callback_role_output.Value.ToString());
if(role_id==0)
{
StateHasChanged();
//NavigationManager.NavigateTo("/userconfirm");
JSRuntime.InvokeVoidAsync("goadmin");
}
else if(role_id==1)
{
Console.WriteLine(role_id);
JSRuntime.InvokeVoidAsync("goleader");
}
else if(role_id==2)
{
Console.WriteLine(role_id);
JSRuntime.InvokeVoidAsync("goofficer");
}
}
/*Console.WriteLine(callback_role_output.Value.ToString());
Console.WriteLine(callback_team_output.Value.ToString());*/
connection.Close();
}
}
}
\ No newline at end of file
@page "/officer"
@inherits OfficerCs
<table class="table">
<thead>
<tr class="header" style="border:1px solid black">
<th>Mission ID</th>
<th>Project Name</th>
<th>Task</th>
<th>Stat</th>
</tr>
</thead>
<tbody>
@if(MissionTable is null)
{
<p>Loading..</p>
}
else
{
Boolean control;
@foreach(var razormtable in MissionTable){
@if(razormtable.user_id==UserData.Data.UserIDData)
{
<tr id="crprrow">
<td>@razormtable.task_assignment_id</td>
@foreach(var task in TaskTable)
{
@if(razormtable.task_id==task.task_id)
{
@foreach (var razorproje in ProjectsTable)
{
@if(task.project_id==razorproje.project_id)
{
<td>@razorproje.project_name</td>
}
}
<td><textarea style="height:50px">@task.task</textarea></td>
}
}
@if(@razormtable.mission_status==0)
{
control=false;
}
else
{
control=true;
}
<td><input type="checkbox" @onchange="eventArgs => { ChangeMissionStat(razormtable.task_assignment_id, eventArgs.Value); }" checked="@control" /></td>
</tr>
}
}
}
</tbody>
</table>
\ 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;
namespace sirkettodo.Pages.OfficerPage
{
public class OfficerCs:ComponentBase
{
[Inject]
public EntitySqlService service{get;set;}
public List<TaskAssignment> MissionTable=new List<TaskAssignment>();
public List<Tasks> TaskTable=new List<Tasks>();
public List<Projects> ProjectsTable=new List<Projects>();
public List<UsersData> UserTable=new List<UsersData>();
[Inject]
IJSRuntime JSRuntime { get; set; }
protected override async Task OnInitializedAsync()
{
if(UserData.Data.UserEmailData != "NULL" && UserData.Data.UserPasswordData != "NULL" && UserData.Data.UserRoleData == 2)
{
ProjectsTable= await Task.Run(() =>service.GetAllProjects());
TaskTable.Clear();
TaskTable=await Task.Run(() =>service.GetAllTasks());;
MissionTable.Clear();
MissionTable=await Task.Run(() =>service.GetAllMissions());
}
else
{
JSRuntime.InvokeVoidAsync("gologin");
}
}
public async void ChangeMissionStat(int MissionID, object checkedValue)
{
bool newIsDone=(bool)checkedValue?true:false;
foreach(TaskAssignment mission in MissionTable)
{
if(mission.task_assignment_id == MissionID)
{
if (newIsDone==true)
{
mission.mission_status = 1;
}
else
{
mission.mission_status = 0;
}
await UpdateMission(mission);
break;
}
}
await OnInitializedAsync();
}
protected async Task UpdateMission(TaskAssignment mission)
{
await service.UpdateTaskAssignmentAsync(mission);
}
}
}
\ No newline at end of file
@page "/register"
<br/>
<div id="register_elemanlari">
<input type="text" @bind="name" @bind:event="oninput" placeholder="İsim" required><br/>
<input type="text" @bind="lastname" @bind:event="oninput" placeholder="Soyisim" required><br/>
<input type="email" @bind="email" @bind:event="oninput" placeholder="Email" required><br/>
<input type="password" @bind="password" @bind:event="oninput" id="input2" placeholder="Şifre" maxlength="8" required><br/>
<input type="button" class="btn btn-warning" @onclick="RegisterButton" value="Kayıt Ol">
<p> Result :@callback</p>
</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 static sirkettodo.Pages.UserData;
namespace sirkettodo.Pages
{
public partial class Register
{
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;}
public void RegisterButton()
{
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";
SqlConnection connection = new SqlConnection(database);
SqlCommand command = connection.CreateCommand();
command.CommandText ="exec register '"+name+"','"+lastname+"','"+
email+"','"+password+"',@callback OUTPUT";
SqlParameter callback_output = command.Parameters.Add("@callback", SqlDbType.Int);
callback_output.Direction = ParameterDirection.Output;
connection.Open();
command.ExecuteScalar();
if(Int32.Parse(callback_output.Value.ToString())==1)
{
callback="Bu kullanıcı zaten var";
}
else if(Int32.Parse(callback_output.Value.ToString())==2)
{
callback="Başarıyla kayıt olundu.Onay verilmesini bekleyin.";
}
Console.WriteLine(callback);
connection.Close();
}
}
}
\ No newline at end of file
@page "/"
@namespace sirkettodo.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = "_Layout";
}
<component type="typeof(App)" render-mode="ServerPrerendered" />
<script src="~/js/admin.js"></script>
<link href="css/froala_editor.min.css" rel="stylesheet" />,
<script src="/js/froala_editor.min.js"></script> ,
<script src="/js/jquery-1.10.2.min.js"></script>
\ No newline at end of file
@using Microsoft.AspNetCore.Components.Web
@namespace sirkettodo.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="sirkettodo.styles.css" rel="stylesheet" />
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head>
<body>
@RenderBody()
<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.server.js"></script>
</body>
</html>
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using sirkettodo.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using sirkettodo.Pages.EntityFramework;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<WeatherForecastService>();
builder.Services.AddScoped<EntitySqlService>();
builder.Services.AddDbContext<MyConnection>(item => item.UseSqlServer(builder.Configuration.GetConnectionString("myconn")));
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:32165",
"sslPort": 44321
}
},
"profiles": {
"sirkettodo": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7087;http://localhost:5222",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
@inherits LayoutComponentBase
@using sirkettodo.Pages
@using static sirkettodo.Pages.UserData
<PageTitle>navmenu</PageTitle>
<div class="page">
<div class="sidebar">
<NavMenu />
</div>
<main>
<div class="top-row px-4">
</div>
<article class="content px-4">
@Body
</article>
</main>
</div>
.page {
position: relative;
display: flex;
flex-direction: column;
}
main {
flex: 1;
}
.sidebar {
background-image: linear-gradient(180deg, rgb(2, 195, 209) 0%, #064726 70%);
}
.top-row {
background-color: #f7f7f7;
border-bottom: 1px solid #d6d5d5;
justify-content: flex-end;
height: 3.5rem;
display: block;
align-items: center;
}
.top-row ::deep a, .top-row .btn-link {
white-space: nowrap;
margin-left: 1.5rem;
}
.top-row a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}
@media (max-width: 640.98px) {
.top-row:not(.auth) {
display: none;
}
.top-row.auth {
justify-content: space-between;
}
.top-row a, .top-row .btn-link {
margin-left: 0;
}
}
@media (min-width: 641px) {
.page {
flex-direction: row;
}
.sidebar {
width: 250px;
height: 100vh;
position: sticky;
top: 0;
}
.top-row {
position: relative;
top: 0;
z-index: 1;
}
.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}
@using sirkettodo.Pages
@using static sirkettodo.Pages.UserData
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">Admin</a>
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<nav class="flex-column">
@if(@Data.UserRoleData==-1)
{
<div class="nav-item px-3">
<NavLink class="nav-link" href="register" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Kayıt Ol
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="login">
<span class="oi oi-account-login" aria-hidden="true"></span> Giriş Yap
</NavLink>
</div>
}
@if(@Data.UserRoleData == 0)
{
<div class="nav-item px-3">
<NavLink class="nav-link" href="userconfirm" Match="NavLinkMatch.All">
<span class="oi oi-lock-unlocked" aria-hidden="true"></span> Kullanıcı Onay
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="teamcrud">
<span class="oi oi-layers" aria-hidden="true"></span> Ekip Güncelle
</NavLink>
</div>
}
@if(@Data.UserRoleData == 1)
{
<div class="nav-item px-3">
<NavLink class="nav-link" href="createproject">
<span class="oi oi-media-play" aria-hidden="true"></span> Proje Oluştur
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="assigntask">
<span class="oi oi-move" aria-hidden="true"></span> Görev Ata
</NavLink>
</div>
}
@if(@Data.UserRoleData == 2)
{
<div class="nav-item px-3">
<NavLink class="nav-link" href="officer">
<span class="oi oi-pencil" aria-hidden="true"></span> Görevlerim
</NavLink>
</div>
}
@if(@Data.UserRoleData != -1)
{
<div class="nav-item px-3">
<NavLink class="nav-link" href="login">
<span class="oi oi-account-login" aria-hidden="true"></span>Çıkış Yap
</NavLink>
</div>
}
</nav>
</div>
@code {
private bool collapseNavMenu = true;
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
}
.navbar-toggler {
background-color: rgba(255, 255, 255, 0.1);
}
.top-row {
height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}
.navbar-brand {
font-size: 1.1rem;
}
.oi {
width: 2rem;
font-size: 1.1rem;
vertical-align: text-top;
top: -2px;
}
.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}
.nav-item:first-of-type {
padding-top: 1rem;
}
.nav-item:last-of-type {
padding-bottom: 1rem;
}
.nav-item ::deep a {
color: #d7d7d7;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
}
.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.25);
color: white;
}
.nav-item ::deep a:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}
@media (min-width: 641px) {
.navbar-toggler {
display: none;
}
.collapse {
/* Never collapse the sidebar for wide screens */
display: block;
}
}
<div class="alert alert-secondary mt-4">
<span class="oi oi-pencil me-2" aria-hidden="true"></span>
<strong>@Title</strong>
<span class="text-nowrap">
Please take our
<a target="_blank" class="font-weight-bold link-dark" href="https://go.microsoft.com/fwlink/?linkid=2149017">brief survey</a>
</span>
and tell us what you think.
</div>
@code {
// Demonstrates how a parent component can supply parameters
[Parameter]
public string? Title { get; set; }
}
@using System.Net.Http
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using sirkettodo
@using sirkettodo.Shared
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings" : {
"myconn": "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"
}
}
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
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