Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/29/13 15:01:23 (11 years ago)
Author:
fschoepp
Message:

#1888:

  • Added views for the billing component (Register users, Create orders and Activate Orders view)
  • Added a mockup for the billing back-end .
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/AccountController.cs

    r8384 r9556  
    5656    }
    5757
    58    
    59     ////
    60     //// GET: /Account/Register
    6158
    62     //public ActionResult Register() {
    63     //  return View();
    64     //}
     59    //
     60    // GET: /Account/Register
    6561
    66     ////
    67     //// POST: /Account/Register
     62    public ActionResult Register() {
     63      return View();
     64    }
    6865
    69     //[HttpPost]
    70     //public ActionResult Register(RegisterModel model) {
    71     //  if (ModelState.IsValid) {
    72     //    // Attempt to register the user
    73     //    MembershipCreateStatus createStatus;
    74     //    Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);
     66    //
     67    // POST: /Account/Register
    7568
    76     //    if (createStatus == MembershipCreateStatus.Success) {
    77     //      FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
    78     //      return RedirectToAction("Index", "Home");
    79     //    }
    80     //    else {
    81     //      ModelState.AddModelError("", ErrorCodeToString(createStatus));
    82     //    }
    83     //  }
     69    [HttpPost]
     70    public ActionResult Register(RegisterModel model) {
     71      if (ModelState.IsValid) {
     72        // Attempt to register the user
     73        MembershipCreateStatus createStatus;
     74        Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);
     75        if (createStatus == MembershipCreateStatus.Success) {
     76          Roles.AddUserToRole(model.UserName, "Web User");
     77          Roles.AddUserToRole(model.UserName, "Hive User");
     78          FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
     79          return RedirectToAction("Index", "Home");
     80        }
     81        else {
     82          ModelState.AddModelError("", ErrorCodeToString(createStatus));
     83        }
     84      }
    8485
    85     //  // If we got this far, something failed, redisplay form
    86     //  return View(model);
    87     //}
     86      // If we got this far, something failed, redisplay form
     87      return View(model);
     88    }
    8889
    89     ////
    90     //// GET: /Account/ChangePassword
     90    //
     91    // GET: /Account/ChangePassword
    9192
    92     //[Authorize]
    93     //public ActionResult ChangePassword() {
    94     //  return View();
    95     //}
     93    [Authorize]
     94    public ActionResult ChangePassword() {
     95      return View();
     96    }
    9697
    97     ////
    98     //// POST: /Account/ChangePassword
     98    //
     99    // POST: /Account/ChangePassword
    99100
    100     //[Authorize]
    101     //[HttpPost]
    102     //public ActionResult ChangePassword(ChangePasswordModel model) {
    103     //  if (ModelState.IsValid) {
     101    [Authorize]
     102    [HttpPost]
     103    public ActionResult ChangePassword(ChangePasswordModel model) {
     104      if (ModelState.IsValid) {
    104105
    105     //    // ChangePassword will throw an exception rather
    106     //    // than return false in certain failure scenarios.
    107     //    bool changePasswordSucceeded;
    108     //    try {
    109     //      MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
    110     //      changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword);
    111     //    }
    112     //    catch (Exception) {
    113     //      changePasswordSucceeded = false;
    114     //    }
     106        // ChangePassword will throw an exception rather
     107        // than return false in certain failure scenarios.
     108        bool changePasswordSucceeded;
     109        try {
     110          MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
     111          changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword);
     112        }
     113        catch (Exception) {
     114          changePasswordSucceeded = false;
     115        }
    115116
    116     //    if (changePasswordSucceeded) {
    117     //      return RedirectToAction("ChangePasswordSuccess");
    118     //    }
    119     //    else {
    120     //      ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
    121     //    }
    122     //  }
     117        if (changePasswordSucceeded) {
     118          return RedirectToAction("ChangePasswordSuccess");
     119        }
     120        else {
     121          ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
     122        }
     123      }
    123124
    124     //  // If we got this far, something failed, redisplay form
    125     //  return View(model);
    126     //}
     125      // If we got this far, something failed, redisplay form
     126      return View(model);
     127    }
    127128
    128     ////
    129     //// GET: /Account/ChangePasswordSuccess
     129    //
     130    // GET: /Account/ChangePasswordSuccess
    130131
    131     //public ActionResult ChangePasswordSuccess() {
    132     //  return View();
    133     //}
     132    public ActionResult ChangePasswordSuccess() {
     133      return View();
     134    }
    134135
    135136    #region Status Codes
Note: See TracChangeset for help on using the changeset viewer.