Example #1
0
        private async System.Threading.Tasks.Task saveHours()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var hours = EntitySaveHelper.GetUserClockForSave(Hours);
                if (hours.UserClockId == null)
                {
                    await DataService.PostItemAsync <UserClock>("userClocks", hours);
                }
                else
                {
                    await DataService.PutItemAsync <UserClock>("userClocks", hours.UserClockIdValue, Hours);
                }

                MessagingCenter.Send <HoursEditViewModel>(this, SUCCESS);
                IsBusy = false;
            }
            catch (Exception ex)
            {
                IsBusy = false;
                ExceptionHelper.ShowException(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        private async System.Threading.Tasks.Task saveLeaveRequest(int status)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var leaveRequest = EntitySaveHelper.GetLeaveRequestForSave(LeaveRequest);
                if (RequestType == SINGLE_DAY)
                {
                    leaveRequest.StartDateTimezoned = leaveRequest.StartDateTimezonedValue.Date;
                    leaveRequest.EndDate            = null;
                }
                else if (RequestType == MULTI_DAY)
                {
                    leaveRequest.StartDateTimezoned = leaveRequest.StartDateTimezonedValue.Date;
                    leaveRequest.EndDateTimezoned   = leaveRequest.EndDateTimezonedValue.Date;
                }

                if (!ForUser && status > 0)
                {
                    var user = LoginHelper.GetLoggedInUser().User;
                    leaveRequest.ApprovedDeniedById = user.UserId;
                    leaveRequest.ApprovedDeniedDate = DateTime.Now;
                    leaveRequest.StatusValue        = status;
                }

                if (leaveRequest.LeaveRequestId == null)
                {
                    await DataService.PostItemAsync <LeaveRequest>("leaveRequests", leaveRequest);
                }
                else
                {
                    await DataService.PutItemAsync <LeaveRequest>("leaveRequests", leaveRequest.LeaveRequestIdValue, leaveRequest);
                }

                MessagingCenter.Send <LeaveRequestEditViewModel>(this, SUCCESS);
                IsBusy = false;
            }
            catch (Exception ex)
            {
                IsBusy = false;
                ExceptionHelper.ShowException(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #3
0
        private async System.Threading.Tasks.Task saveEntry()
        {
            IsBusy = true;
            try
            {
                var forSave = EntitySaveHelper.GetEntryForSave(Entry);
                var url     = EntryType == 1 ? "generalentries" : "entries";
                if (Entry.EntryId != null)
                {
                    var saved = await DataService.PutItemAsync <DataLayer.Models.Entry>(url, forSave.EntryId.Value, forSave);

                    Entry.EntryId = saved.EntryId;
                }
                else
                {
                    var saved = await DataService.PostItemAsync <DataLayer.Models.Entry>(url, forSave);

                    Entry.EntryId = saved.EntryId;
                }
                EntrySaved?.Invoke(Entry, new EventArgs());
                MessagingCenter.Send <EntryEditViewModel>(this, SUCCESS);
                IsBusy = false;
            }
            catch (Exception ex)
            {
                IsBusy = false;
                if (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                ExceptionHelper.ShowException(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }