コード例 #1
0
ファイル: UserController.cs プロジェクト: cobianwae/Pear
        public ActionResult Create(CreateUserViewModel viewModel)
        {
            var request = viewModel.MapTo<CreateUserRequest>();
            var response = _userService.Create(request);
            TempData["IsSuccess"] = response.IsSuccess;
            TempData["Message"] = response.Message;
            if (response.IsSuccess)
            {
                return RedirectToAction("Index");
            }

            return View("Create", viewModel);
        }
コード例 #2
0
ファイル: UserController.cs プロジェクト: fazar/Pear
        public ActionResult Create(CreateUserViewModel viewModel)
        {
            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);

                    if (!Directory.Exists(Path.Combine(Server.MapPath("~/Content/signature/"))))
                    {
                        Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Content/signature/")));
                    }
                    var path = Path.Combine(Server.MapPath("~/Content/signature/"), fileName);
                    var url = "/Content/signature/" + fileName;

                    file.SaveAs(path);
                    viewModel.SignatureImage = url;
                }
            }
            var request = viewModel.MapTo<CreateUserRequest>();
            var response = _userService.Create(request);
            TempData["IsSuccess"] = response.IsSuccess;
            TempData["Message"] = response.Message;
            if (response.IsSuccess)
            {
                return RedirectToAction("Index");
            }

            return View("Create", viewModel);
        }