Exemplo n.º 1
0
        public JsonResult Edit(StudentSourceItemEntity ajaxData)
        {
            if (ajaxData.SourceName == "" || ajaxData.SourceNameEn == "")
                return Json(new { SaveResult = false, Msg = "来源名称不能为空!" });

            repository.Save(ajaxData);
            return Json(new { SaveResult = true, Msg = "保存成功" });
        }
Exemplo n.º 2
0
        public void Save(StudentSourceItemEntity sourceItem)
        {
            StudentSourceItemEntity originSource = context.StudentSourceItem.SingleOrDefault(s => s.SourceName == sourceItem.SourceName);
            if (originSource == null)
                context.StudentSourceItem.Add(sourceItem);
            else
                context.Entry(originSource).CurrentValues.SetValues(sourceItem);

            context.SaveChanges();
        }