2024-11-03 19:42:19 +04:00
|
|
|
|
using EventVisitorClientApp.Models;
|
|
|
|
|
using EventVisitorLogic.BindingModels;
|
|
|
|
|
using EventVisitorLogic.Logic;
|
|
|
|
|
using EventVisitorLogic.ViewModels;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
2024-11-04 19:46:16 +04:00
|
|
|
|
using System.Net.NetworkInformation;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Numerics;
|
2024-11-03 19:42:19 +04:00
|
|
|
|
using System.Security.Cryptography.Xml;
|
2024-11-04 19:46:16 +04:00
|
|
|
|
using System.Xml.Linq;
|
2024-11-03 19:42:19 +04:00
|
|
|
|
|
|
|
|
|
namespace EventVisitorClientApp.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
Random rnd = new Random();
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Enter()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Enter(string login, string password)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
2024-11-04 19:46:16 +04:00
|
|
|
|
APIClient.Client = APIClient.GetRequest<OrganizerViewModel>($"api/Organizer/login?login={login}&password={password}");
|
2024-11-03 19:42:19 +04:00
|
|
|
|
if (APIClient.Client == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
Response.Redirect("Index");
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Privacy()
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Client == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIClient.Client);
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Privacy(string login, string password, string surname, string name, string lastname, string role, string organizationName, string phone)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Client == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(login))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> e-mail");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(surname))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(organizationName))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(role))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/client/updatedata", new OrganizerBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = APIClient.Client.Id,
|
|
|
|
|
Name = name,
|
|
|
|
|
Surname = surname,
|
|
|
|
|
LastName = lastname,
|
|
|
|
|
Role = role,
|
|
|
|
|
OrganizationName = organizationName,
|
|
|
|
|
Phone = phone,
|
|
|
|
|
Email = login,
|
|
|
|
|
Password = password
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
APIClient.Client.Name = name;
|
|
|
|
|
APIClient.Client.Surname = surname;
|
|
|
|
|
APIClient.Client.LastName = lastname;
|
|
|
|
|
APIClient.Client.Role = role;
|
|
|
|
|
APIClient.Client.OrganizationName = organizationName;
|
|
|
|
|
APIClient.Client.Phone = phone;
|
|
|
|
|
APIClient.Client.Email = login;
|
|
|
|
|
APIClient.Client.Password = password;
|
|
|
|
|
Response.Redirect("Index");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Register()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Register(string login, string password, string surname, string name, string lastname, string role, string organizationName, string phone, string code)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(login))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> e-mail");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(surname))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(organizationName))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(role))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
APIClient.PostRequest("api/Organizer/Register", new OrganizerBindingModel
|
|
|
|
|
{
|
|
|
|
|
Name = name,
|
|
|
|
|
Surname = surname,
|
|
|
|
|
LastName = lastname,
|
|
|
|
|
Role = role,
|
|
|
|
|
OrganizationName = organizationName,
|
|
|
|
|
Phone = phone,
|
|
|
|
|
Email = login,
|
|
|
|
|
Password = password
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("Enter");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult MyEvents()
|
|
|
|
|
{
|
2024-11-04 19:46:16 +04:00
|
|
|
|
if (APIClient.Client == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIClient.GetRequest<List<EventViewModel>>($"api/main/GetEventList?ClientId={APIClient.Client.Id}"));
|
2024-11-03 19:42:19 +04:00
|
|
|
|
}
|
|
|
|
|
public IActionResult CreateEvent()
|
|
|
|
|
{
|
2024-11-04 19:46:16 +04:00
|
|
|
|
if (APIClient.Client == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult ViewEvent(int id)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Client == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var eventDetails = APIClient.GetRequest<EventViewModel>($"api/main/GetEvent?EventId={id}");
|
|
|
|
|
|
|
|
|
|
return View(eventDetails);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void CreateEvent(string name, string description, string type, string phone, string email, string address, string city, string status, int count, DateTime timestart, DateTime timeend)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Client == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/main/createevent", new EventBindingModel
|
|
|
|
|
{
|
|
|
|
|
Name = name,
|
|
|
|
|
Description = description,
|
|
|
|
|
Type = type,
|
|
|
|
|
ContactPhone = phone,
|
|
|
|
|
Address = address,
|
|
|
|
|
City = city,
|
|
|
|
|
Status = status,
|
|
|
|
|
ContactEmail = email,
|
|
|
|
|
TimeEnd = timeend.ToUniversalTime(),
|
|
|
|
|
TimeStart = timestart.ToUniversalTime(),
|
|
|
|
|
Date = DateTime.Now.ToUniversalTime(),
|
|
|
|
|
CountVisitors = count,
|
|
|
|
|
FreePlaces = count,
|
|
|
|
|
OrganizerId = APIClient.Client.Id
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("MyEvents");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult DeleteEvent(int id)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (APIClient.Client == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
APIClient.PostRequest($"api/main/DeleteEvent", new EventBindingModel { Id = id });
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return RedirectToAction("MyEvents");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult UpdateEvent(int id)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Client == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
var eventDetails = APIClient.GetRequest<EventViewModel>($"api/main/GetEvent?EventId={id}");
|
|
|
|
|
|
|
|
|
|
return View(eventDetails);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void UpdateEvent(int id, string name, string description, string type, string phone, string email, string address, string city, string status, int count, DateTime timestart, DateTime timeend)
|
|
|
|
|
{
|
|
|
|
|
if (APIClient.Client == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
APIClient.PostRequest("api/main/UpdateEvent", new EventBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = id,
|
|
|
|
|
Name = name,
|
|
|
|
|
Description = description,
|
|
|
|
|
Type = type,
|
|
|
|
|
ContactPhone = phone,
|
|
|
|
|
Address = address,
|
|
|
|
|
City = city,
|
|
|
|
|
Status = status,
|
|
|
|
|
ContactEmail = email,
|
|
|
|
|
TimeEnd = timeend.ToUniversalTime(),
|
|
|
|
|
TimeStart = timestart.ToUniversalTime(),
|
|
|
|
|
Date = DateTime.Now.ToUniversalTime(),
|
|
|
|
|
CountVisitors = count,
|
|
|
|
|
FreePlaces = count,
|
|
|
|
|
OrganizerId = APIClient.Client.Id
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("MyEvents");
|
2024-11-03 19:42:19 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|