Example #1
0
        public string Update(Profile profile)
        {
            SsdsContainer c1 = DbContext.OpenContainer("Profile");
            var           p  = c1.Single <Profile>(c => c.Entity.OpenId == profile.OpenId &&
                                                   c.Entity.IdType == profile.IdType
                                                   );

            if (p == null)
            {
                profile.LogOnTime    = DateTime.Now;
                profile.RegisterTime = DateTime.Now;
                profile.Role         = "User";
                profile.Id           = Guid.NewGuid().ToString();
                c1.Insert(new SsdsEntity <Profile>
                {
                    Id     = profile.Id,
                    Kind   = "Profile",
                    Entity = profile,
                });
                return(profile.Id);
            }
            var newp = p.Entity;

            newp.Name = profile.Name;
            //if (profile.Name == "Öصä")
            //    newp.Role = "Admin";
            newp.NickName      = profile.NickName;
            newp.School        = profile.School;
            newp.SchoolDetails = profile.SchoolDetails;
            newp.Sex           = profile.Sex;
            c1.Update(newp, p.Id, ConcurrencyPattern.IfNoneMatch);
            return(p.Id);
        }
Example #2
0
        public static void Update(this SsdsContainer source, IEnumerable <SsdsBlobEntity> entities, Func <SsdsBlobEntity, Exception, bool> onError)
        {
            object concurrency = new object();

            Parallel.ForEach <SsdsBlobEntity>(entities, delegate(SsdsBlobEntity entity, ParallelState ps)
            {
                try
                {
                    source.Update(entity);
                }
                catch (Exception ex)
                {
                    lock (concurrency)
                    {
                        if (!ps.IsStopped)
                        {
                            if (onError != null)
                            {
                                if (!onError(entity, ex))
                                {
                                    ps.Stop();
                                }
                            }
                        }
                    }
                }
            });
        }
Example #3
0
        public void Update(Wiki wiki)
        {
            SsdsContainer c1 = DbContext.OpenContainer("Wiki");
            var           m  = c1.Single <Wiki>(c => c.Id == wiki.Id).Entity;

            m.Title = wiki.Title;
            m.Body  = wiki.Body;
            c1.Update <Wiki>(m, wiki.Id, ConcurrencyPattern.Always);
        }
Example #4
0
        public void Update(Question question)
        {
            SsdsContainer c1 = DbContext.OpenContainer("Question");
            var           q  = c1.Single <Question>(c => c.Id == question.Id).Entity;

            q.Title       = question.Title;
            q.Body        = question.Body;
            q.MemoryLimit = question.MemoryLimit;
            q.TimeLimit   = question.TimeLimit;
            q.Test        = question.Test;
            q.GroupId     = question.GroupId;
            c1.Update <Question>(q, question.Id, ConcurrencyPattern.Always);
        }