예제 #1
0
        public async Task <List <hnNotifyItem> > ShowItem()
        {
            NotifyContext db = this._dbconn;
            var           q  = await(from p in db.hnNotifyItem where p.deleted == 0 select p).ToAsyncEnumerable().ToList();

            return(q);
        }
예제 #2
0
        public async Task <List <hnNotify> > ShowMember(int member_counter)
        {
            NotifyContext db = this._dbconn;
            var           q  = await(from p in db.hnNotify where p.deleted == 0 && p.member_counter == member_counter select p).ToAsyncEnumerable().ToList();

            return(q);
        }
예제 #3
0
        public async Task delUserServiceOrder(int member_counter, string actionName, string serviceName)
        {
            NotifyContext db = this._dbconn;

            var q1 = (from p in db.hnNotifyItem where p.name == serviceName select p).AsEnumerable().FirstOrDefault();
            var q  = (from p in db.hnNotify where p.member_counter == member_counter && p.hnNotifyItem_counter == q1.counter select p)
                     .AsEnumerable().FirstOrDefault();
            var a = db.hnNotify.Find(q.counter);

            db.hnNotify.Attach(a);
            if (actionName == "Line")
            {
                a.Line = 0;
            }
            if (actionName == "Mail")
            {
                a.Mail = 0;
            }
            if (actionName == "Message")
            {
                a.Message = 0;
            }

            await db.SaveChangesAsync();
        }
예제 #4
0
        public async Task addLineToken(int counter, string Token)
        {
            NotifyContext db      = this._dbconn;
            var           _member = db.Members.Find(counter);

            db.Members.Attach(_member);
            _member.LineToken = Token;
            await db.SaveChangesAsync();
        }
예제 #5
0
        public async Task updateMember(hnNotify _hnNotify)
        {
            NotifyContext db      = this._dbconn;
            var           _member = db.hnNotify.Find(_hnNotify.counter);

            db.hnNotify.Attach(_member);
            // _member = _hnNotify;
            _member.Line    = _hnNotify.Line;
            _member.Mail    = _hnNotify.Mail;
            _member.Message = _hnNotify.Message;
            await db.SaveChangesAsync();
        }
예제 #6
0
        public async Task <List <DTOhnNotifyItem> > ShowMemberItem(int member_counter)
        {
            NotifyContext db      = this._dbconn;
            var           q       = await(from p in db.hnNotify where p.deleted == 0 && p.member_counter == member_counter select p).ToAsyncEnumerable().ToList();
            var           tmpList = new List <DTOhnNotifyItem> ();

            foreach (var p in db.hnNotifyItem.Where(c => c.deleted == 0))
            {
                var DTO = new DTOhnNotifyItem();
                DTO.counter = p.counter;
                DTO.name    = p.name;
                var p2 = q.Where(c => c.hnNotifyItem_counter == p.counter).FirstOrDefault();
                if (p2 != null)
                {
                    if (p2.Line == 1)
                    {
                        DTO.Line = true;
                    }
                    else
                    {
                        DTO.Line = false;
                    }

                    if (p2.Mail == 1)
                    {
                        DTO.Mail = true;
                    }
                    else
                    {
                        DTO.Mail = false;
                    }

                    if (p2.Message == 1)
                    {
                        DTO.Message = true;
                    }
                    else
                    {
                        DTO.Message = false;
                    }
                }
                else
                {
                    DTO.Line    = false;
                    DTO.Mail    = false;
                    DTO.Message = false;
                }
                tmpList.Add(DTO);
            }
            return(tmpList);
        }
예제 #7
0
        public async Task <List <USERSERVICEORDER> > ShowMemberOrderItem(int member_counter)
        {
            NotifyContext db = this._dbconn;
            var           q  = await(from p in db.hnNotify join p2 in db.hnNotifyItem on p.hnNotifyItem_counter equals p2.counter where p.deleted == 0 && p.member_counter == member_counter select new {
                Line        = p.Line,
                Mail        = p.Mail,
                Message     = p.Message,
                serviceName = p2.name
            }).ToAsyncEnumerable().ToList();

            List <USERSERVICEORDER> l = new List <USERSERVICEORDER> ();

            foreach (var p in q)
            {
                if (p.Line == 1)
                {
                    USERSERVICEORDER d = new USERSERVICEORDER();
                    d.actionName  = "Line";
                    d.serviceName = p.serviceName;
                    l.Add(d);
                }

                if (p.Mail == 1)
                {
                    USERSERVICEORDER d = new USERSERVICEORDER();
                    d.actionName  = "Mail";
                    d.serviceName = p.serviceName;
                    l.Add(d);
                }

                if (p.Message == 1)
                {
                    USERSERVICEORDER d = new USERSERVICEORDER();
                    d.actionName  = "Message";
                    d.serviceName = p.serviceName;
                    l.Add(d);
                }
            }

            l = l.OrderBy(c => c.actionName).ToList();
            return(l);
        }
예제 #8
0
        public async Task <Members> accountLogin(string account, string password)
        {
            NotifyContext db = this._dbconn;
            var           q  = await(from p in db.Members where p.deleted == 0 && account == p.account select p).ToAsyncEnumerable().FirstOrDefault();

            return(q);
            // if (q == null) {
            //     // 沒有資料列
            //     Members _member = new Members();
            //     _member.counter = -1;
            //     return _member;
            // } else if (q.password == password) {
            //     // 登入成功
            //     return q;

            // } else {
            //     // 密碼錯誤
            //     q.counter = 0;
            //     return q;

            // }
        }
예제 #9
0
 public hnNotifyService(NotifyContext dbconn)
 {
     this._dbconn = dbconn;
 }
예제 #10
0
        public void UpdateNotifyMember(DTOhnNotifyItemUser dto)
        {
            NotifyContext db = this._dbconn;
            var           q  = (from p in db.hnNotify where p.member_counter == dto.member_counter select p)
                               .AsEnumerable().ToList();

            if (q.FirstOrDefault() == null)
            {
                foreach (var p in dto.DTOhnNotifyItems)
                {
                    var _hnNotify = new hnNotify();
                    _hnNotify.member_counter       = dto.member_counter;
                    _hnNotify.counter              = Guid.NewGuid();
                    _hnNotify.hnNotifyItem_counter = p.counter;
                    if (p.Line == true)
                    {
                        _hnNotify.Line = 1;
                    }
                    else
                    {
                        _hnNotify.Line = 0;
                    }

                    if (p.Mail == true)
                    {
                        _hnNotify.Mail = 1;
                    }
                    else
                    {
                        _hnNotify.Mail = 0;
                    }

                    if (p.Message == true)
                    {
                        _hnNotify.Message = 1;
                    }
                    else
                    {
                        _hnNotify.Message = 0;
                    }

                    _hnNotify.deleted = 0;
                    db.hnNotify.Add(_hnNotify);
                    db.SaveChanges();
                }
            }
            else
            {
                foreach (var p in q)
                {
                    var _hnNotify = db.hnNotify.Find(p.counter);
                    db.hnNotify.Attach(_hnNotify);
                    _hnNotify.deleted = 0;
                    foreach (var p1 in dto.DTOhnNotifyItems)
                    {
                        if (p.hnNotifyItem_counter == p1.counter)
                        {
                            if (p1.Line == true)
                            {
                                _hnNotify.Line = 1;
                            }
                            else
                            {
                                _hnNotify.Line = 0;
                            }

                            if (p1.Mail == true)
                            {
                                _hnNotify.Mail = 1;
                            }
                            else
                            {
                                _hnNotify.Mail = 0;
                            }

                            if (p1.Message == true)
                            {
                                _hnNotify.Message = 1;
                            }
                            else
                            {
                                _hnNotify.Message = 0;
                            }
                        }
                    }
                }
                db.SaveChanges();
            }
        }
예제 #11
0
 public MemberService(NotifyContext dbconn)
 {
     this._dbconn = dbconn;
 }