Beispiel #1
0
        public async Task NewEmail(string id)
        {
            // 根据id获取组
            var group = LiteDb.SingleOrDefault <Group>(g => g._id == id);

            if (group == null)
            {
                await ResponseErrorAsync($"未通过{id}找到组");

                return;
            }
            // 根据key来进行实例化
            EmailInfo res;

            if (group.groupType == "send")
            {
                var emailInfo = Body.ToObject <SendBox>();
                res = LiteDb.Upsert2(g => g.email == emailInfo.email, emailInfo);
            }
            else
            {
                var emailInfo = Body.ToObject <ReceiveBox>();
                res = LiteDb.Upsert2(g => g.email == emailInfo.email, emailInfo);
            }

            await ResponseSuccessAsync(res);
        }
Beispiel #2
0
        public async Task GetEmails(string id)
        {
            var group = LiteDb.SingleOrDefault <Group>(g => g._id == id);

            if (group == null)
            {
                await ResponseErrorAsync($"未通过{id}找到组");

                return;
            }

            List <EmailInfo> results = new List <EmailInfo>();

            if (group.groupType == "send")
            {
                var emails = LiteDb.Fetch <SendBox>(e => e.groupId == id).ToList();
                results.AddRange(emails);
            }
            else
            {
                var emails = LiteDb.Fetch <ReceiveBox>(e => e.groupId == id).ToList();
                results.AddRange(emails);
            }

            await ResponseSuccessAsync(results);
        }
Beispiel #3
0
        public async Task NewEmails(string id)
        {
            // 获取所有待更新的key
            var group = LiteDb.SingleOrDefault <Group>(g => g._id == id);

            if (group == null)
            {
                await ResponseErrorAsync($"未通过{id}找到组");

                return;
            }
            // 根据key来进行实例化
            if (group.groupType == "send")
            {
                var emailInfos = Body.ToObject <List <SendBox> >();
                emailInfos.ForEach(e => e.groupId = id);
                LiteDb.Database.GetCollection <SendBox>().InsertBulk(emailInfos);
                await ResponseSuccessAsync(emailInfos);
            }
            else
            {
                var emailInfos = Body.ToObject <List <ReceiveBox> >();
                emailInfos.ForEach(e => e.groupId = id);
                LiteDb.Database.GetCollection <ReceiveBox>().InsertBulk(emailInfos);
                await ResponseSuccessAsync(emailInfos);
            }
        }
        public async Task GetTemplates(string id)
        {
            // 获取用户名
            var result = LiteDb.SingleOrDefault <Template>(t => t.userId == Token.UserId && t._id == id);

            await ResponseSuccessAsync(result);
        }
Beispiel #5
0
        public async Task DeleteEmails(string id)
        {
            var group = LiteDb.SingleOrDefault <Group>($"_id='{id}'");

            if (group == null)
            {
                await ResponseErrorAsync($"未通过{id}找到组");

                return;
            }

            // 删除组id对应的所有邮箱
            LiteDb.DeleteMany <SendBox>($"groupId='{id}'");
            LiteDb.DeleteMany <ReceiveBox>($"groupId='{id}'");

            await ResponseSuccessAsync("success");
        }
        public async Task GetUserSettings()
        {
            Setting setting = LiteDb.SingleOrDefault <Setting>(s => s.userId == Token.UserId);

            await ResponseSuccessAsync(setting);
        }