Example #1
0
        public string PostUpdate([FromBody] MemCard memCard)
        {
            using (var db = new BloggingContext())
            {
                try
                {
                    var query = from b in db.MemCards
                                where b.mobile == memCard.mobile
                                select b;
                    var memcards = query.ToList();
                    if (memcards.Count > 0)
                    {
                        var memcard = memcards[0];
                        memcard.Name = memCard.Name;
                        if (memCard.address != null)
                        {
                            memcard.address = memCard.address;
                        }
                        if (memCard.sex != null)
                        {
                            memcard.sex = memCard.sex;
                        }
                        if (memCard.birthday != null)
                        {
                            memcard.birthday = memCard.birthday;
                        }
                    }

                    db.SaveChanges();
                    var result = new Results
                    {
                        Code = 0,
                        msg  = "会员信息同步成功!"
                    };
                    return(JsonConvert.SerializeObject(result));

                    ;
                }
                catch (Exception e)
                {
                    var result = new Results
                    {
                        Code = -1,
                        msg  = "会员信息同步失败!"
                    };
                    return(JsonConvert.SerializeObject(result));
                }
            }
        }
Example #2
0
        private MemCard AddNewMemCards(string mobile, string newCardno)
        {
            //var newCardno = "e0582800";
            var memCards = new MemCard
            {
                Name      = "",
                sex       = "",
                certif_no = "",
                birthday  = null,
                //email="",
                //lever="0",//default 0,--0会员卡 1贵宾卡
                state   = 0,        //default 0,    -- 0= 新发卡 1= 正常卡 9= 已删除
                address = "",
                Card_no = newCardno //会员卡号
            };

            return(memCards);
        }