Example #1
0
        public Z_Harag_Post UpdatePost(PostForPostListModel postForPostModel, int cutomerId, IList <string> files, List <string> errors)
        {
            DeletePostPhohos(postForPostModel.Id);

            List <KeyAndValue> filesUrl = UploadFiles(files, errors);

            if (errors.Count > 0)
            {
                return(null);
            }
            var postE = _postRepository.Table.Where(m => m.Id == postForPostModel.Id).FirstOrDefault();

            postE.Text        = postForPostModel.Text;
            postE.Title       = postForPostModel.Title;
            postE.CategoryId  = postForPostModel.CategoryId;
            postE.CityId      = postForPostModel.CityId;
            postE.Contact     = postForPostModel.Contact;
            postE.DateUpdated = DateTime.Now;


            foreach (var item in filesUrl)
            {
                if (item.Key.ToLower() == "image")
                {
                    postE.Z_Harag_Photo.Add(new Z_Harag_Photo()
                    {
                        Url = item.Value
                    });
                }
            }
            _postRepository.Update(postE);


            return(postE);
        }
Example #2
0
        public Z_Harag_Post AddNewPost(PostForPostListModel postForPostModel, int cutomerId, IList <string> files, List <string> errors)
        {
            List <KeyAndValue> filesUrl = UploadFiles(files, errors);

            if (errors.Count > 0)
            {
                return(null);
            }

            var post = new Z_Harag_Post()
            {
                Text               = postForPostModel.Text,
                Title              = postForPostModel.Title,
                CategoryId         = postForPostModel.CategoryId,
                CityId             = postForPostModel.CityId,
                Contact            = postForPostModel.Contact,
                CustomerId         = cutomerId,
                DateCreated        = DateTime.Now,
                IsAnswered         = false,
                IsCommentingClosed = false,
                IsDispayed         = false,
                DateUpdated        = DateTime.Now,
                IsDeleted          = false,
                IsOrder            = postForPostModel.IsOrder,
                IsFeatured         = false,
                IsCommon           = false,
                Tags               = postForPostModel.Tags
            };

            foreach (var item in filesUrl)
            {
                if (item.Key.ToLower() == "image")
                {
                    post.Z_Harag_Photo.Add(new Z_Harag_Photo()
                    {
                        Url = item.Value
                    });
                }
            }

            _postRepository.Insert(post);


            return(post);
        }