/// <summary> /// /// </summary> /// <param name="jsonItemEdit"></param> /// <returns></returns> public int AddJsonItem(JsonItemEditDto jsonItemEdit) { var r = IocUnity.Get <RepositoryItem>().IsItem(jsonItemEdit.ParentId); if (r) { var id = IdentityHelper.NewSequentialGuid().ToString("N"); TItemContent itemContent = jsonItemEdit.MapTo <TItemContent>(); itemContent.Id = id; itemContent.IsHasChildren = false; itemContent.CreateTime = DateTime.Now; itemContent.ParentId = null; itemContent.UpdateTime = null; itemContent.ItemId = jsonItemEdit.ParentId; return(IocUnity.Get <RepositoryItemContent>().Insert(itemContent)); } else { var id = IdentityHelper.NewSequentialGuid().ToString("N"); TItemContent itemContent = jsonItemEdit.MapTo <TItemContent>(); itemContent.Id = id; itemContent.CreateTime = DateTime.Now; itemContent.UpdateTime = null; itemContent.ParentId = jsonItemEdit.ParentId; itemContent.ItemId = null; int count = 0; IocUnity.Get <RepositoryItemContent>().DapperRepository.ExcuteTransaction(c => { count = IocUnity.Get <RepositoryItemContent>().Insert(itemContent); IocUnity.Get <RepositoryItemContent>() .Update("IsHasChildren", true, "Id", jsonItemEdit.ParentId); }); return(count); } }
/// <summary> /// /// </summary> /// <param name="jsonItemEdit"></param> /// <returns></returns> public int EditJsonItem(JsonItemEditDto jsonItemEdit) { TItemContent itemContent = jsonItemEdit.MapTo <TItemContent>(); itemContent.UpdateTime = DateTime.Now; return(IocUnity.Get <RepositoryItemContent>().Update(jsonItemEdit.MapTo <TItemContent>())); }