public ActionResult Register(FormCollection formCollection)
        {
            //Get formCollection in key parameters
            var name     = formCollection.Get("firstName") ?? "";
            var email    = formCollection.Get("email") ?? "";
            var password = formCollection.Get("password") ?? "";

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                ViewBag.successMessage = "Error";
                return(View());
            }
            var requestRegisterRq = new TODOListApplication.ServiceModel.Account.RegisterRq();

            requestRegisterRq.Name     = name;
            requestRegisterRq.Email    = email;
            requestRegisterRq.Password = password;
            WCFService.AccountService accountServiceClient = new WCFService.AccountService();
            WCFService.ToDoService    toDoService          = new WCFService.ToDoService();

            var result = accountServiceClient.Register(requestRegisterRq);

            toDoService.AddToDo(new AddToDoRq {
                Name = "Welcome ToDo List", UserId = result.UserId
            });
            ViewBag.successMessage = "Success";

            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Add(FormCollection formCollection)
        {
            var userId      = GetSession.UserId;
            var toDoService = new WCFService.ToDoService();
            var request     = new AddToDoRq {
                Name = formCollection.Get("name") ?? "", UserId = userId
            };
            var result = toDoService.AddToDo(request);

            ViewBag.RedirectToDoId = result.ToDoId;
            return(RedirectToAction("GetToDo", new { id = result.ToDoId }));
        }