Exemplo n.º 1
0
        public IActionResult Create(UserView userView, IFormFile inputphoto)
        {
            userView.DayCreate = DateTime.Now;
            userView.DayEdited = DateTime.Now;
            userView.Status    = true;
            string FileNameSave = "default.jpg";

            if (inputphoto != null)
            {
                FileNameSave = FileCuaSang.SaveFile(webHostEnvironment, inputphoto, "assets/image");
            }
            userView.Photo = FileNameSave;
            int id = 0;

            if (ModelState.IsValid)
            {
                id = UserBus.Create(userView);
            }
            switch (id)
            {
            case -1:
                ViewBag.Result = -1;
                break;

            case 0:
                ViewBag.Result = 0;
                break;

            default:
                return(RedirectToAction("index"));
            }
            return(View(userView));
        }