Exemplo n.º 1
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();
        }
Exemplo n.º 2
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();
            }
        }