public virtual async Task <ApiActionResult> CreateAsync(TCreateModel model) { try { if (model == null) { return(null); } var userId = GetUserGuidId(); string uniqueId = UniqueIDHelper.GenarateRandomString(12); TEntity entity = new TEntity(); entity.InjectFrom(model); entity.SetValueByNameIfExists("CreatedBy", userId); entity.SetValueByNameIfExists("CreatedDate", DateTime.UtcNow); entity.SetValueByNameIfExists("LastModifiedBy", userId); entity.SetValueByNameIfExists("LastModifiedDate", DateTime.UtcNow); entity.SetValueByNameIfExists("Deleted", false); entity.SetValueByNameIfExists("UniqueId", uniqueId); var result = await _repository.CreateEntityAsync(entity, userId); var viewModel = new TViewModel(); viewModel.InjectFrom(result.ResponseData); return(await ApiActionResult.SuccessAsync(viewModel)); } catch (Exception ex) { return(await ApiActionResult.FailedAsync(ex.Message)); } }