コード例 #1
0
        public static ArticlePrimitive GetPrimitive(this Article entity)
        {
            ArticlePrimitive primitive = new ArticlePrimitive();

                primitive.Id = entity.Id;

                primitive.User_Id = entity.User_Id;

                primitive.Title = entity.Title;

                primitive.Info = entity.Info;

                primitive.FullText = entity.FullText;

                primitive.CreateTime = entity.CreateTime;

                primitive.DeleteTime = entity.DeleteTime;

                primitive.Position = entity.Position;

                return primitive;
        }
コード例 #2
0
        public static ArticlePrimitive GetPrimitiveCopy(this ArticlePrimitive primitiveToCopy)
        {
            if (primitiveToCopy == null) return null;

                ArticlePrimitive primitive = new ArticlePrimitive();

                primitive.Id = primitiveToCopy.Id;

                primitive.User_Id = primitiveToCopy.User_Id;

                primitive.Title = primitiveToCopy.Title;

                primitive.Info = primitiveToCopy.Info;

                primitive.FullText = primitiveToCopy.FullText;

                primitive.CreateTime = primitiveToCopy.CreateTime;

                primitive.DeleteTime = primitiveToCopy.DeleteTime;

                primitive.Position = primitiveToCopy.Position;

                return primitive;
        }
コード例 #3
0
        public ArticlePrimitive CreateOrUpdateArticle(ArticlePrimitive articlePrimitive, SectionPrimitive sectionPrimitive)
        {
            try
              {
            using (AtSolutionEntities context = new AtSolutionEntities())
            {
              Article entity = articlePrimitive.GetEntity();

              Article existingEntity = context.Articles.Where(x => x.Id == articlePrimitive.Id).FirstOrDefault();

              //no record of this item in the DB, item being passed in has a PK
              if (existingEntity == null && entity.Id > 0)
              {
            throw new FaultException<ExceptionDetail>(new ExceptionDetail(new Exception("Błąd zapisu do bazy")),
                                                        "Obiekt nie istniał w bazie, a jego Id jest większe od 0.");
              }
              //Item has no PK value, must be new
              else if (entity.Id <= 0)
              {
            context.Articles.AddObject(entity);
              }
              //Item was retrieved, and the item passed has a valid ID, do an update
              else
              {
            context.Articles.ApplyCurrentValues(entity);
              }

              context.SaveChanges();
              return entity;
            }
              }
              catch (Exception e)
              {
            throw new FaultException<ExceptionDetail>(new ExceptionDetail(e), e.Message);
              }
        }
コード例 #4
0
 public ForumItemPrimitive CreateOrUpdateForumItem(ForumItemPrimitive forumItemPrimitive, ArticlePrimitive articlePrimitive)
 {
     throw new NotImplementedException();
 }