public IActionResult Edit(PersonalCreateModel model) { var response = ResponseModelFactory.CreateInstance; if (ConfigurationManager.AppSettings.IsTrialVersion) { response.SetIsTrial(); return(Ok(response)); } using (_dbContext) { var entity = _dbContext.PersonalDiary.FirstOrDefault(x => x.PersonalDiaryUuid == model.PersonalDiaryUuid); entity.Headline = model.Headline; //标题 entity.Content = model.Content; //内容 entity.WriteTime = model.WriteTime; //撰写时间 entity.Accessory = model.Accessory; //附件 _dbContext.SaveChanges(); return(Ok(response)); } }
public IActionResult Create(PersonalCreateModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var personaldiary = new PersonalDiary(); personaldiary.Headline = model.Headline; //标题 personaldiary.Content = model.Content; //内容 personaldiary.WriteTime = Convert.ToDateTime(model.WriteTime.ToString()).ToString("yyyy-MM-dd HH:mm:ss"); //撰写时间 personaldiary.Accessory = model.Accessory; //附件 personaldiary.EstablishTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //添加时间 personaldiary.EstablishName = AuthContextService.CurrentUser.DisplayName; //添加人 personaldiary.IsDeleted = 0; //是否删除 _dbContext.PersonalDiary.Add(personaldiary); _dbContext.SaveChanges(); response.SetSuccess(); return(Ok(response)); } }