Esempio n. 1
0
        public ActionResult EditTeam(VmTeam model)
        {
            model.CurrentUserId = CurrentUserId;

            var oldUrl = model.TeamImageUrl;
            var result = true;
            var blTeam = new BLTeam();

            try
            {
                if (ModelState.IsValid)
                {
                    if (model.UploadedDocument != null)
                    {
                        model.TeamImageUrl = UIHelper.UploadFile(model.UploadedDocument, "/Resources/Uploaded/Teams/" + CurrentUserId.Replace("-", ""));
                    }
                }
                result = blTeam.UpdateTeam(model);
            }
            catch (Exception ex)
            {
                result = false;
            }

            //if (result != false && !string.IsNullOrEmpty(model.TeamImageUrl))
            //{
            //    UIHelper.DeleteFile(oldUrl);
            //}

            if (result == false)
            {
                model.ActionMessageHandler.Message = "Operation has been failed...\n call system Admin";
            }

            var jsonData = new
            {
                teamTitle   = model.Name,
                teamIconUrl = model.TeamImageUrl,
                teamId      = model.Id,
                success     = result,
                message     = model.ActionMessageHandler.Message = "Operation has been succeeded"
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));

            //return View("../Author/TeamEdit", model);
        }