Beispiel #1
0
        private async Task SubmitNewPost()
        {
            if (ValidateFields())
            {
                PostUpsertRequest request = new PostUpsertRequest
                {
                    AdminName       = APIService.Username,
                    IsGlobal        = false,
                    UserRelatedId   = APIService.loggedProfile.UserId,
                    Opphoto         = APIService.loggedProfile.UserPhoto,
                    PostDateTime    = DateTime.Now,
                    PostText        = PostText,
                    PostTitle       = PostTitle,
                    ReviewRelatedId = null,
                    PostPhoto       = PostPhoto
                };
                if (PlaceholderArtist.ArtistId != 0)
                {
                    request.ArtistRelatedId = PlaceholderArtist.ArtistId;
                }
                else
                {
                    request.ArtistRelatedId = null;
                }
                await _postService.Insert <Model.Post>(request);

                await Application.Current.MainPage.DisplayAlert("Success", "You have successfully added a post", "OK");

                RefreshFields();
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Error", "Post title and text cannot be empty", "OK");
            }
        }
Beispiel #2
0
        public MPost Insert(PostUpsertRequest insert)
        {
            var newObj = _mapper.Map <Post>(insert);

            _context.Posts.Add(newObj);
            _context.SaveChanges();
            return(_mapper.Map <MPost>(newObj));
        }
Beispiel #3
0
        public MPost Update(int Id, PostUpsertRequest update)
        {
            var obj = _context.Posts.Find(Id);

            _context.Posts.Attach(obj);
            _context.Posts.Update(obj);
            _mapper.Map(update, obj);
            _context.SaveChanges();
            return(_mapper.Map <MPost>(obj));
        }
 public MPost Update(int Id, PostUpsertRequest update)
 {
     return(_service.Update(Id, update));
 }
 public MPost Insert(PostUpsertRequest insert)
 {
     return(_service.Insert(insert));
 }