Beispiel #1
0
        public ActionResult Index(CustomPerkTask model)
        {
            string sMessage = "";

            if (ModelState.IsValid)
            {
                TittleUserServices service = new TittleUserServices();
                long   nID      = 0;
                string filename = "";
                if (model.image != null && model.image.ContentLength > 0)
                {
                    string websiteUrl = ConfigurationManager.AppSettings["WebsiteUrl"].ToString();
                    string filePath   = ConfigurationManager.AppSettings["TaskIconPath"].ToString();
                    filename = RandomString(15) + Path.GetExtension(model.image.FileName);
                    string fullPath = Server.MapPath(filePath + "/" + filename);
                    if (!Directory.Exists(Server.MapPath(filePath)))
                    {
                        Directory.CreateDirectory(Server.MapPath(filePath));
                    }
                    model.image.SaveAs(fullPath);
                    model.icon = websiteUrl + filePath + "/" + filename;
                }
                sMessage = service.SaveOrUpdatePerkTask(model, ref nID);
            }

            return(Json(new
            {
                message = sMessage
            }));
        }