protected TaskTemplateContainerWrapper ToTaskTemplateContainerWrapper(TaskTemplateContainer item) { return(ToTaskListTemplateContainerWrapper(new List <TaskTemplateContainer> { item }).FirstOrDefault()); }
public virtual int SaveOrUpdate(TaskTemplateContainer item) { if (item.ID == 0 && Db.ExecuteScalar <int>(Query("crm_task_template_container").SelectCount().Where(Exp.Eq("id", item.ID))) == 0) { item.ID = Db.ExecuteScalar <int>( Insert("crm_task_template_container") .InColumnValue("id", 0) .InColumnValue("title", item.Title) .InColumnValue("entity_type", (int)item.EntityType) .InColumnValue("create_on", DateTime.UtcNow) .InColumnValue("create_by", ASC.Core.SecurityContext.CurrentAccount.ID) .InColumnValue("last_modifed_on", DateTime.UtcNow) .InColumnValue("last_modifed_by", ASC.Core.SecurityContext.CurrentAccount.ID) .Identity(1, 0, true)); } else { Db.ExecuteScalar <int>( Update("crm_task_template_container") .Set("title", item.Title) .Set("entity_type", (int)item.EntityType) .Set("last_modifed_on", DateTime.UtcNow) .Set("last_modifed_by", ASC.Core.SecurityContext.CurrentAccount.ID) .Where(Exp.Eq("id", item.ID))); } return(item.ID); }
public TaskTemplateContainerWrapper CreateTaskTemplateContainer(string entityType, string title) { if (string.IsNullOrEmpty(title)) { throw new ArgumentException(); } var taskTemplateContainer = new TaskTemplateContainer { EntityType = ToEntityType(entityType), Title = title }; taskTemplateContainer.ID = DaoFactory.TaskTemplateContainerDao.SaveOrUpdate(taskTemplateContainer); return(ToTaskTemplateContainerWrapper(taskTemplateContainer)); }
public TaskTemplateContainerDto CreateTaskTemplateContainer([FromRoute] string entityType, [FromBody] string title) { if (string.IsNullOrEmpty(title)) { throw new ArgumentException(); } var taskTemplateContainer = new TaskTemplateContainer { EntityType = ToEntityType(entityType), Title = title }; taskTemplateContainer.ID = _daoFactory.GetTaskTemplateContainerDao().SaveOrUpdate(taskTemplateContainer); return(ToTaskTemplateContainerDto(taskTemplateContainer)); }
public int SaveOrUpdate(TaskTemplateContainer item) { var dbEntity = new DbTaskTemplateContainer { Id = item.ID, Title = item.Title, EntityType = item.EntityType, CreateOn = item.CreateOn == DateTime.MinValue ? DateTime.UtcNow : item.CreateOn, CreateBy = item.CreateBy == Guid.Empty ? _securityContext.CurrentAccount.ID : item.CreateBy, LastModifedOn = DateTime.UtcNow, LastModifedBy = _securityContext.CurrentAccount.ID, TenantId = TenantID }; CrmDbContext.Update(dbEntity); CrmDbContext.SaveChanges(); return(dbEntity.Id); }