Exemplo n.º 1
0
        public ActionResult Onboarding(TenantDetailsModel model, HttpPostedFileBase imageFile)
        {
            var fs     = Request.Files;
            var isAjax = Request.IsAjaxRequest();

            if (ModelState.IsValid)
            {
                var userName = User.Identity.Name;
                if (String.IsNullOrEmpty(userName))
                {
                    return(Json(new { Success = false, ErrorMsg = "User does not exist!" }));
                }
                var login        = AccountService.GetLoginByEmail(userName);
                var tenant       = login == null ? null : TenantService.GetTenantByLogin(login);
                var detailResult = TenantService.SaveDetails(model, login);
                if (detailResult.IsSuccess)
                {
                    var files       = Request.Files;
                    var mediaResult = TenantService.AddTenantMediaFiles(Request.Files, tenant, Server.MapPath("~/images"));
                    if (isAjax)
                    {
                        return(Json(new { Success = true }));
                    }
                    else
                    {
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    return(Json(new { Success = false }));
                }
            }
            return(View(model));
        }