public async void SaveClickedAsync(object sender, EventArgs e)
        {
            var form = new FormAnnouncement
            {
                Title    = Title.Text,
                Contents = Contents.Text
            };

            if (form.Title.Length < 3)
            {
                DependencyService.Get <IMessage>().ShowShortTime("Başlık en az 3 karakter olmalıdır.");
            }

            if (form.Contents.Length < 25)
            {
                DependencyService.Get <IMessage>().ShowShortTime("İçerik en az 25 karakter olmalıdır.");
            }

            if (form.Title.Length < 3 || form.Contents.Length < 25)
            {
                return;
            }

            if (FormAnnouncement.Id.HasValue)
            {
                form.Id = FormAnnouncement.Id.Value;
            }

            var result = await AnnouncementService.CreateOrUpdateAsync(form);

            if (result.Data.HasValue)
            {
                await Navigation.PopAsync();
            }
        }
        public async Task <ShowResponse> UpdateAsync(FormAnnouncement announcement)
        {
            string path = $"/announcement/{announcement.Id.Value}";

            var response = await RequestService.PutAsync(path, announcement);

            var result = new ShowResponse(response);

            string message;

            if (result.StatusCode.Equals(HttpStatusCode.OK))
            {
                message = "Duyurunuz güncellendi.";
            }
            else
            if (result.StatusCode.Equals(HttpStatusCode.Unauthorized))
            {
                message = "Tekrar giriş yapmanız gerekmektedir.";
            }
            else
            {
                message = "Duyurunuz oluşturulamadı.";
            }

            DependencyService.Get <IMessage>().ShowShortTime(message);

            return(result);
        }
        public AnnouncementFormPage()
        {
            InitializeComponent();

            FormAnnouncement = new FormAnnouncement();

            InitializeForm();
        }
        public AnnouncementFormPage(FormAnnouncement formAnnouncement)
        {
            InitializeComponent();

            FormAnnouncement = formAnnouncement;

            InitializeForm();
        }
示例#5
0
        void EditMenuClicked(object sender, EventArgs e)
        {
            var formAnnouncement = new FormAnnouncement()
            {
                Id       = Announcement.Id,
                Title    = Announcement.Title,
                Contents = Announcement.Contents
            };

            Navigation.PushAsync(new AnnouncementFormPage(formAnnouncement));
        }
 public async Task <ShowResponse> CreateOrUpdateAsync(FormAnnouncement annoncement)
 {
     if (annoncement.Id.HasValue)
     {
         return(await UpdateAsync(annoncement));
     }
     else
     {
         return(await CreateAsync(annoncement));
     }
 }