Добавлен: 24.05.2023
Просмотров: 160
Скачиваний: 5
{
ViewBag.Title = "Страничка Директора!!!";
EFUsersRepository data=new EFUsersRepository();
ViewBag.dan = data.GetUsers().Where(x => x.Status == 2);
return View();
}
[Authorize(Users = "tank")]
[HttpGet]
public ActionResult Create()
{
return View();
}
[Authorize(Users = "tank")]
[HttpGet]
public ActionResult Delete(int id)
{
DataManager dat=new DataManager();
dat.Users.UserDelete(id);
ViewBag.Tank=id.ToString();
return View();
// return RedirectToAction("direct_admin");
}
[Authorize(Users = "tank")]
[HttpPost]
public ActionResult Create(menViewModel model)
{
if (ModelState.IsValid)
{
data = new DataManager();
MembershipCreateStatus status = data.MembershipProvider.CreateUser(model.UserName, model.Password,
model.Email, model.FirstName,
model.LastName,
model.MiddleName, 2);
if (status == MembershipCreateStatus.Success)
return View("message");
ModelState.AddModelError("", GetMembershipCreateStatusResultText(status));
}
return View(model);
}
//Создаем текст ошибки для MembershipCreateStatus
[Authorize(Users = "tank")]
public string GetMembershipCreateStatusResultText(MembershipCreateStatus status)
{
if (status == MembershipCreateStatus.DuplicateEmail)
return "Менеджер с таким email адресом уже существует";
if (status == MembershipCreateStatus.DuplicateUserName)
return "Менеджер с таким именем адресом уже существует";
return "Неизвестная ошибка";
}
[Authorize(Users = "tank")]
[HttpGet]
public ActionResult Rezult()
{
EFPokypkaRepository pk=new EFPokypkaRepository();
ViewBag.dan = pk.GetPokypka();
return View();
} }}
Исходный текст модуля отображенья информации в виде html страничек.
@model PK.Models.RegisterViewModel
@{
ViewBag.Title = "Регистрация на сайте";
}
<h2>Регистрация на сайте</h2>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Форма регистрации!!!</legend>
<br/>
<div class="editor-field">
Логин: @Html.EditorFor(model => model.UserName)
@Html.ValidationMessageFor(model => model.UserName)
</div>
<br/>
<div class="editor-field">
Пароль: @Html.EditorFor(model => model.Password)
@Html.ValidationMessageFor(model => model.Password)
</div>
<br/>
<div class="editor-field">
Пароль еще раз: @Html.EditorFor(model => model.ConfirmPassword)
@Html.ValidationMessageFor(model => model.ConfirmPassword)
</div>
<br/>
<div class="editor-field">
Email: @Html.EditorFor(model => model.Email)
@Html.ValidationMessageFor(model => model.Email)
</div>
<br/>
<div class="editor-field">
Email еще раз: @Html.EditorFor(model => model.ConfirmEmail)
@Html.ValidationMessageFor(model => model.ConfirmEmail)
</div>
<br/>
<div class="editor-field">
Фамилия: @Html.EditorFor(model => model.FirstName)
@Html.ValidationMessageFor(model => model.FirstName)
</div>
<br/>
<div class="editor-field">
Имя: @Html.EditorFor(model => model.LastName)
@Html.ValidationMessageFor(model => model.LastName)
</div>
<br/>
<div class="editor-field">
Отчество: @Html.EditorFor(model => model.MiddleName)
@Html.ValidationMessageFor(model => model.MiddleName)