EnVisageOnline/Main-RMO/Source/EnVisage/Views/Account/Manage.cshtml

130 lines
4.7 KiB
Plaintext

@using EnVisage.Models;
@using Microsoft.AspNet.Identity;
@model EnVisage.Models.ManageUserViewModel
@{
ViewBag.Title = "Manage Account";
}
<h2>@ViewBag.Title.</h2>
<p class="text-success">@ViewBag.StatusMessage</p>
<div class="row">
<div class="col-md-12">
@if (ViewBag.HasLocalPassword)
{
@Html.Partial("_ChangePasswordPartial")
}
else
{
@Html.Partial("_SetPasswordPartial")
}
<div class="panel-body">
<div class="form-group">
@Html.LabelFor(model => model.FirstName, new { @class = "col-sm-2 control-label" })
<div class="col-sm-10">
@Html.TextBoxFor(model => model.FirstName, new { @class = "form-control firstname editField" })
@Html.ValidationMessageFor(model => model.FirstName)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.LastName, new { @class = "col-sm-2 control-label" })
<div class="col-sm-10">
@Html.TextBoxFor(model => model.LastName, new { @class = "form-control lastname" ,@disabled="disabled" })
@Html.ValidationMessageFor(model => model.LastName)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Email, new { @class = "col-sm-2 control-label" })
<div class="col-sm-10">
@Html.TextBoxFor(model => model.Email, new { @class = "form-control email editField" })
@Html.ValidationMessageFor(model => model.Email)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Phone, new { @class = "col-sm-2 control-label" })
<div class="col-sm-10">
@Html.TextBoxFor(model => model.Phone, new { @class = "form-control phone editField" })
@Html.ValidationMessageFor(model => model.Phone)
</div>
</div>
<div class="form-group" style="margin-top: 20px;margin-bottom: 20px;">
@Html.LabelFor(model => model.PreferredResourceAllocation, new { @class = "col-sm-2 control-label" })
<div class="col-sm-10">
@Html.CheckBoxFor(model => model.PreferredResourceAllocation, new { @id = "preferredallocation"})
</div>
</div>
<div class="form-group" style="margin-top: 20px;margin-bottom: 20px;">
@Html.LabelFor(model => model.PreferredTotalsDisplaying, new { @class = "col-sm-2 control-label" })
<div class="col-sm-10">
@Html.CheckBoxFor(model => model.PreferredTotalsDisplaying, new { @id = "PreferredTotalsDisplaying"})
</div>
</div>
<div class="form-group" style="margin-top: 20px;margin-bottom: 20px;">
<div class="col-sm-2"></div>
<div class="col-sm-10">
<button class="btn btn-success" id="btnsave" onclick="changeEmailAndPhone()"><i class="fa fa-save"></i> Save</button>
</div>
</div>
</div>
@*<section id="externalLogins">
@Html.Action("RemoveAccountList")
@Html.Partial("_ExternalLoginsListPartial", new { Action = "LinkLogin", ReturnUrl = ViewBag.ReturnUrl })
</section>*@
</div>
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
init.push(function () {
$('#preferredallocation').switcher({
on_state_content: 'Number of Resources',
off_state_content: 'Number of Hours'
});
$('#preferredallocation').parent().css("width", "140px");
$('#PreferredTotalsDisplaying').switcher({
on_state_content: 'Average',
off_state_content: 'Sum'
});
$('#PreferredTotalsDisplaying').parent().css("width", "140px");
});
$("#btnsave").prop("disabled",true);
$("#PreferredTotalsDisplaying").on("change", function (e) {
$("#btnsave").prop("disabled", false);
});
$("#preferredallocation").on("change", function (e) {
$("#btnsave").prop("disabled", false);
});
$(".editField").on("change", function (e) {
$("#btnsave").prop("disabled", false);
});
function changeEmailAndPhone() {
var email = $('.email').val();
var phone = $('.phone').val();
var firstname = $('.firstname').val();
var lastname = $('.lastname').val();
var alloc = $('#preferredallocation').is(':checked');
var displayTotals = $('#PreferredTotalsDisplaying').is(':checked');
var param = { newEmail: email, newPhone: phone, newPreferredResourceAllocation: alloc, newPreferredTotalsDisplaying: displayTotals,FirstName:firstname,LastName:lastname };
blockUI();
$.post('@Url.Action("ChangeEmailAndPhone", "Account")', param, function (data) {
unblockUI();
if (data.Status == 'OK') {
bootbox.alert("Your changes have been processed", function () {
var url = "/Home/Index";
window.location.href = url;
});
} else if (data.Status == 'Error') {
console.debug(data.Exception);
showErrorModal('Update error.', data.Msg);
}
});
}
</script>
}