Esempio n. 1
0
        /// <summary>
        /// 修改活动
        /// </summary>
        /// <param name="id">活动ID</param>
        /// <returns></returns>
        public ActionResult EditActivity(int id)
        {
            ViewClass          model  = new ViewClass();
            ClassServiceClient client = new ClassServiceClient();

            model = client.Get(id);

            ViewBag.Title = "编辑活动";
            ViewBag.Id    = id;
            YogaDicItemServiceClient dicClient = new YogaDicItemServiceClient();

            ViewData["YogaTopic"] = (from topic in (dicClient.Dics(d => d.DicId == CommonInfo.Topic))
                                     select new SelectListItem()
            {
                Text = topic.ItemName,
                Value = topic.ID.ToString(),
                Selected = model.TopicIds.Split(',').Contains(topic.ID.ToString())
            }).ToList();
            //逐层获取地理位置区域
            List <DistrictModel> DistrictModelList = client.GetDistrictModel(model.AreaID);

            ViewBag.DistrictModelList = Newtonsoft.Json.JsonConvert.SerializeObject(DistrictModelList);

            //获取活动关联的老师并拼成HTML展示在页面
            ClassTeacherServiceClient subClient         = new ClassTeacherServiceClient();
            List <ViewClassTeacher>   ClassTeacherModel = subClient.GetClass_Id(id);
            string html = "";

            if (ClassTeacherModel != null)
            {
                foreach (var item in ClassTeacherModel)
                {
                    html += "<li class=teacher id=teacher_" + item.Id + ""
                            + " teacherid=" + item.TeacherId + "><div class=teacher-info><div class=name><img src=" + item.Avatar + "> "
                            + item.Name + "<span>" + item.Gender + "</span> <span>"
                            + item.Country + "</span> <span>" + item.YogaSystem + "</span></div></div><div class=teacher-close>&nbsp;</div></li>";
                }
            }
            ViewData["html"] = new MvcHtmlString(html);
            string centerHtml = "";
            CentersServiceClient centerClient = new CentersServiceClient();

            if (!string.IsNullOrWhiteSpace(model.CenterID))
            {
                var centerList = centerClient.GetCentersListByClassCenterID(model.CenterID);
                foreach (var dataItem in centerList)
                {
                    centerHtml += "<li class=Center id=CenterID_" + dataItem.CenterId + " CenterID=" + dataItem.CenterId
                                  + "><div class=Center-info><div class=name><img src=" + dataItem.CenterPortraint + "/> " + dataItem.CenterName
                                  + " </div></div><div class=Center-close>&nbsp;</div></li>";
                }
            }
            ViewData["centerHtml"] = new MvcHtmlString(centerHtml);
            return(View(model));
        }
Esempio n. 2
0
        public JsonResult EditActivity(ViewClass entity)
        {
            ClassServiceClient client = new ClassServiceClient();
            ViewClass          model  = client.Get(entity.Id);

            model.Address       = entity.Address;
            model.AreaID        = entity.AreaID;
            model.Banner        = entity.Banner;
            model.ClassType     = entity.ClassType;
            model.Content       = entity.Content;
            model.Creater       = entity.Creater;
            model.CreateTime    = DateTime.Now;
            model.Discount      = entity.Discount;
            model.Duration      = entity.Duration;
            model.DurationUnit  = entity.DurationUnit;
            model.InterestCount = entity.InterestCount;
            model.Max           = entity.Max;
            model.Name          = entity.Name;
            model.Price         = entity.Price;
            model.Start         = entity.Start;
            model.Summary       = entity.Summary;
            model.Tags          = entity.Tags;
            model.TopicIds      = entity.TopicIds;
            model.CloseTime     = entity.CloseTime;
            model.CenterID      = entity.CenterID;
            if (entity.DurationUnit == 1)
            {
                entity.EndTime = Convert.ToDateTime(entity.Start).AddHours(entity.Duration);
            }
            else
            {
                entity.EndTime = Convert.ToDateTime(entity.Start).AddDays(entity.Duration);
            }
            ClassTeacherServiceClient subClient = new ClassTeacherServiceClient();
            List <ViewClassTeacher>   list      = subClient.GetClass_Id(entity.Id);

            if (!string.IsNullOrEmpty(entity.TeacherIds) && entity.Id > 0)
            {
                subClient.EditTeachers(entity.Id, entity.TeacherIds);
            }
            client.Edit(model);
            return(Json(entity));
        }