public async Task <DaoResultMessage> CreateRecordTemplateEntity(string id, RecordTemplateEntity entity) { DaoResultMessage message = new DaoResultMessage(); try { using (var context = new DjLiveCpContext()) { entity.Id = id; var item = context.RecordTemplate.Add(entity); await context.SaveChangesAsync(); message.Code = DaoResultCode.Success; message.Message = "添加成功!"; message.para = item; } } catch (Exception e) { LogHelper.Error(e.Message, e); message.Code = DaoResultCode.UnExpectError; message.Message = e.Message; } return(message); }
public async Task <DaoResultMessage> Add2Account(string accountId, RecordTemplateEntity entity) { DaoResultMessage message = new DaoResultMessage(); try { using (var context = new DjLiveCpContext()) { var dbentity = context.Account.FirstOrDefault(obj => obj.Id == accountId); if (dbentity != null) { entity.AccountEntities.Add(dbentity); context.RecordTemplate.Add(entity); await context.SaveChangesAsync(); } else { message.Code = DaoResultCode.ItemNotExist; message.Message = "修改失败,对象不存在!"; } } } catch (Exception e) { LogHelper.Error(e.Message, e); message.Code = DaoResultCode.UnExpectError; message.Message = e.Message; } return(message); }
public async Task <int> GetRecordTemplatesCount(string userId, RecordTemplateEntity entityDelta) { try { using (var context = new DjLiveCpContext()) { var sql = $@"SELECT Count(0) FROM sys_recordtemplate"; var paraObjects = new object[] { }; if (!string.IsNullOrEmpty(userId)) { sql = $@"SELECT Count(0) FROM sys_recordtemplate as b join sys_alli_account_recordtemplate as c on c.AccountId = {"{0}"} and b.Id = c.TemplateId"; paraObjects = new object[] { userId }; } var objs = context.Database.SqlQuery <int>(sql, paraObjects); return(await objs.FirstOrDefaultAsync()); } } catch (Exception e) { LogHelper.Error(e.Message, e); return(0); } }
public static DvRecordOption Parse2Conf(this RecordTemplateEntity secureEntity) { DvRecordOption option = new DvRecordOption(); if (secureEntity != null) { option.enabled = "on"; } else { option.enabled = "off"; } return(option); }
public async Task <DaoResultMessage> UpdateRecordTemplateEntity(string id, RecordTemplateEntity entity) { DaoResultMessage message = new DaoResultMessage(); try { using (var context = new DjLiveCpContext()) { var dbentity = context.RecordTemplate.FirstOrDefault(obj => obj.Id == id); if (dbentity != null && entity != null) { dbentity.Description = entity.Description; dbentity.NamePolicy = entity.NamePolicy; dbentity.UploadUrl = entity.UploadUrl; context.RecordTemplate.Attach(dbentity); context.Entry(dbentity).Property(x => x.Id).IsModified = false; context.Entry(dbentity).Property(x => x.Name).IsModified = false; context.Entry(dbentity).Property(x => x.Description).IsModified = !entity.Description.IsStringNull(); context.Entry(dbentity).Property(x => x.NamePolicy).IsModified = !entity.NamePolicy.IsStringNull(); context.Entry(dbentity).Property(x => x.UploadUrl).IsModified = !entity.UploadUrl.IsStringNull(); await context.SaveChangesAsync(); message.Code = DaoResultCode.Success; message.Message = "修改成功!"; message.para = entity; } else { message.Code = DaoResultCode.ItemNotExist; message.Message = "修改失败,对象不存在!"; } } } catch (Exception e) { LogHelper.Error(e.Message, e); message.Code = DaoResultCode.UnExpectError; message.Message = e.Message; } return(message); }
public async Task <int> GetRecordTemplatesCount(string userId, RecordTemplateModel delta) { try { RecordTemplateEntity entityDelta = null; if (delta != null) { entityDelta = new RecordTemplateEntity() { Name = delta.Name }; } return(await RecordDao.GetRecordTemplatesCount(userId, entityDelta)); } catch (Exception e) { throw; } }
public Task <int> SubmitForm(RecordTemplateEntity entity, string keyValue) { var claimsIdentity = _httpContext.HttpContext.User.Identity as ClaimsIdentity; claimsIdentity.CheckArgumentIsNull(nameof(claimsIdentity)); var claim = claimsIdentity?.FindFirst(t => t.Type == ClaimTypes.NameIdentifier); if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); entity.F_LastModifyUserId = claim?.Value; return(_service.UpdateAsync(entity)); } else { entity.Create(); entity.F_CreatorUserId = claim?.Value; return(_service.InsertAsync(entity)); } }
public async Task <IActionResult> AddRecordTemplate([FromBody] AddRecordTemplateInput input) { var userId = _usersService.GetCurrentUserId(); var entity = new RecordTemplateEntity { F_Id = Common.GuId(), F_EnabledMark = true, F_CreatorTime = DateTime.Now, F_CreatorUserId = userId, F_Title = input.title, F_Content = input.content, F_IsPrivate = input.isPrivate }; await _recordTemplateApp.InsertForm(entity); var data = new { id = entity.F_Id }; return(Ok(data)); }
public async Task <List <RecordTemplateEntity> > GetRecordTemplateEntitys(int page, int countPerPage, string userId = "", RecordTemplateEntity delta = null) { try { using (var context = new DjLiveCpContext()) { var sql = $@"SELECT * FROM sys_recordtemplate limit {(page - 1) * countPerPage},{countPerPage}"; var paraObjects = new object[] { }; if (!string.IsNullOrEmpty(userId)) { sql = $@"SELECT * FROM sys_recordtemplate as b join sys_alli_account_recordtemplate as c on c.AccountId = {"{0}"} and b.Id = c.TemplateId limit {(page - 1) * countPerPage},{countPerPage}"; paraObjects = new object[] { userId }; } var objs = context.Database.SqlQuery <RecordTemplateEntity>(sql, paraObjects); return(await objs.ToListAsync()); } } catch (Exception e) { LogHelper.Error(e.Message, e); return(null); } }
public Task <int> InsertForm(RecordTemplateEntity entity) { return(_service.InsertAsync(entity)); }
public Task <int> UpdateForm(RecordTemplateEntity entity) { return(_service.UpdateAsync(entity)); }