Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int Create(ICNUser item)
- {
- return this._repository.Create(item);
- }
- public void Update(ICNUser item)
- {
- this._repository.Create(item);
- }
- public IGenericActionResponse<ICNUser> Create(ICNUser item)
- {
- return this._repository.Create(item);
- }
- public IGenericActionResponse Update(ICNUser item)
- {
- return this._repository.Update(item);
- }
- namespace Web.ActionResponses
- {
- public enum ActionResponseCode
- {
- Success,
- RecordNotFound,
- InvalidCreateHash,
- ExpiredCreateHash,
- ExpiredModifyHash,
- UnableToCreateRecord,
- UnableToUpdateRecord,
- UnableToSoftDeleteRecord,
- UnableToHardDeleteRecord,
- UserAlreadyExists,
- EmailCannotBeBlank,
- PasswordCannotBeBlank,
- PasswordResetHashExpired,
- AccountNotActivated,
- InvalidEmail,
- InvalidPassword,
- InvalidPageAction
- }
- public interface IGenericActionResponse
- {
- bool RequestSuccessful { get; }
- ActionResponseCode ResponseCode { get; }
- }
- public interface IGenericActionResponse<T>
- {
- bool RequestSuccessful { get; }
- bool RecordIsNull{get;}
- ActionResponseCode ResponseCode { get; }
- }
- }
- namespace Web.ActionResponses
- {
- public class GenericActionResponse<T> : IGenericActionResponse<T>
- {
- private bool _requestSuccessful;
- private ActionResponseCode _actionResponseCode;
- public T Item { get; set; }
- public GenericActionResponse(bool success, ActionResponseCode actionResponseCode, T item)
- {
- this._requestSuccessful = success;
- this._actionResponseCode = actionResponseCode;
- this.Item = item;
- }
- public GenericActionResponse(bool success, ActionResponseCode actionResponseCode)
- {
- this._requestSuccessful = success;
- this._actionResponseCode = actionResponseCode;
- this.Item = default(T);
- }
- public bool RecordIsNull
- {
- get
- {
- return this.Item == null;
- }
- }
- public bool RequestSuccessful
- {
- get
- {
- return this._requestSuccessful;
- }
- }
- public ActionResponseCode ResponseCode
- {
- get
- {
- return this._actionResponseCode;
- }
- }
- }
- public class GenericActionResponse : IGenericActionResponse
- {
- private bool _requestSuccessful;
- private ActionResponseCode _actionResponseCode;
- public GenericActionResponse(bool success, ActionResponseCode actionResponseCode)
- {
- this._requestSuccessful = success;
- this._actionResponseCode = actionResponseCode;
- }
- public bool RequestSuccessful
- {
- get
- {
- return this._requestSuccessful;
- }
- }
- public ActionResponseCode ResponseCode
- {
- get
- {
- return this._actionResponseCode;
- }
- }
- }}
- public ActionResult ValidateResetHash(string passwordResetHash)
- {
- IGenericActionResponse result = (IGenericActionResponse)this._userManager.IsValidPasswordResetHash(passwordResetHash);
- if (result.RequestSuccessful)
- {
- Models.PasswordChangeModel model = new Models.PasswordChangeModel();
- model.PasswordResetHash = passwordResetHash;
- return View("~/Areas/Public/Views/ResetPassword/PasswordChangeForm.cshtml", model);
- }
- else
- {
- switch (result.ResponseCode)
- {
- case ActionResponseCode.RecordNotFound:
- {
- FermataFish.Models.GenericActionModel responseModel = new FermataFish.Models.GenericActionModel(true, "/Login", "Login", "You have submitted an invalid password reset link.", false);
- return View("~/Views/Shared/GenericAction.cshtml", responseModel);
- }
- case ActionResponseCode.PasswordResetHashExpired:
- {
- FermataFish.Models.GenericActionModel responseModel = new FermataFish.Models.GenericActionModel(true, "/ResetPassword", "Reset Password", "You have submitted an expired password reset link. You must reset your password again to change it.", false);
- return View("~/Views/Shared/GenericAction.cshtml", responseModel);
- }
- default:
- {
- FermataFish.Models.GenericActionModel responseModel = new FermataFish.Models.GenericActionModel(true, "/", "Home", "An unknown error has occured. The system administrator has been notified. Error code:" + Enum.GetName(typeof(ActionResponseCode), result.ResponseCode), false);
- return View("~/Views/Shared/GenericAction.cshtml", responseModel);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement