public IActionResult EditModel(string TempName, string TempTable, string TempType, string ModelOrgId, string JsonData, string ModelIndex) { string urlContentPath = @"\Content\" + ModelOrgId + @"\" + TempName + ".xml"; var modeltemp = new ModelTempDto() { TempName = TempName, TempTable = TempTable, ModelOrgId = ModelOrgId, TempType = TempType, Id = ModelIndex, ContentPath = urlContentPath }; string urlPath = _hostEnvironment.WebRootPath; urlContentPath = urlPath + urlContentPath; List <ModelEntityDto> listDto = JsonConvert.DeserializeObject <List <ModelEntityDto> >(JsonData); OtherHelper.CreateListXml <ModelEntityDto>(urlContentPath, listDto); _tempService.Add(modeltemp); List <ModelEntityDto> list = OtherHelper.SerialierList <ModelEntityDto>(urlContentPath); return(Json(new JsonResult <string> { msg = "模板保存成功!", flag = true })); }
public async Task <bool> Add(ModelTempDto model) { var entity = _context.ModelTemp.Find(model.Id); string sql = string.Empty; try { if (entity.Id.IsNotBlank()) { entity = _mapper.MapperSource <ModelTempDto, ModelTempEntity>(model, entity); _context.Entry(entity).State = Microsoft.EntityFrameworkCore.EntityState.Modified; sql = GeneralSqlHelper <ModelTempEntity> .GeneralSQL(SQLEnum.Update); entity.LastUpdateTime = DateTime.Now; } else { entity.InitEntity(); _context.ModelTemp.Add(entity); } } catch (Exception ex) { throw new Exception(ex.Message); } await _context.SaveChangesAsync(); return(true); }