Exemple #1
0
        public ActionResult AdministratePlansSave(PlanTemplateModel model, HttpPostedFileBase file)
        {
            if (file != null)
            {
                if (HasImageExtension(file.FileName))
                {
                    if (file.ContentLength > 0)
                    {
                        using (var binaryReader = new BinaryReader(file.InputStream))
                        {
                            byte[] imageData = null;
                            imageData        = binaryReader.ReadBytes(file.ContentLength);
                            model.ImgContent = imageData;
                        }
                    }
                }
            }

            var planTemplate = new PlanTemplate();

            var savedPlan = planTemplate.PutPlanTemplate(model);

            if (savedPlan != null)
            {
                return(RedirectToAction("AdministratePlans", "Administration"));
            }

            return(RedirectToAction("AdministratePlans", "Administration"));
        }
Exemple #2
0
        public PlanTemplateModel PostPlanTemplate(PlanTemplateModel model)
        {
            PlanTemplateModel result = null;

            using (var httpClient = new HttpClient())
            {
                var json = JsonConvert.SerializeObject(model);

                var content = new StringContent(json, Encoding.UTF8, "application/json");

                var response = httpClient.PostAsync("http://localhost:64483/api/SportTemplate/", content).Result;

                if (response.IsSuccessStatusCode)
                {
                    var jsonResult = response.Content.ReadAsStringAsync().Result;

                    result = JsonConvert.DeserializeObject <PlanTemplateModel>(jsonResult);
                }
                return(result);
            }
        }