Ejemplo n.º 1
0
        public async Task UpdateSendEmailSettings(string id)
        {
            // 根据id判断属于发件还是收件
            var sendbox = LiteDb.FirstOrDefault <SendBox>(s => s._id == id);

            if (sendbox != null)
            {
                if (sendbox.settings == null)
                {
                    sendbox.settings = new SendBoxSetting();
                }

                sendbox.settings.UpdateObject(Body as JObject);
                LiteDb.Update(sendbox);
                await ResponseSuccessAsync(sendbox);

                return;
            }

            await ResponseErrorAsync($"未找到发件箱:{id}");
        }
Ejemplo n.º 2
0
        public async Task ModifyEmail(string id)
        {
            // 根据id判断属于发件还是收件
            var sendbox = LiteDb.FirstOrDefault <SendBox>(s => s._id == id);

            if (sendbox != null)
            {
                var updateData1 = Body.ToObject <SendBox>();
                var result1     = LiteDb.Upsert2(e => e._id == id, updateData1, new UpdateOptions(true)
                {
                    "_id", "groupId"
                });
                await ResponseSuccessAsync(result1);

                return;
            }

            // 收件情况
            var receiveBox = LiteDb.FirstOrDefault <ReceiveBox>(r => r._id == id);

            if (receiveBox == null)
            {
                await ResponseErrorAsync($"未找到id:{id}对应的邮箱");

                return;
            }

            var updateData2 = Body.ToObject <ReceiveBox>();
            // 更新
            var result2 = LiteDb.Upsert2(e => e._id == id, updateData2, new UpdateOptions(true)
            {
                "_id", "groupId"
            });

            ResponseSuccessAsync(result2);
        }