Ejemplo n.º 1
0
        async Task <bool> AddSharedFile()
        {
            try
            {
                string filePath = App.Current.Properties["defaultPid"].ToString() + "/files/upload/";

                newButton.IsEnabled = false;
                MemoryStream stream     = new MemoryStream(fileArray);
                var          fileUpload = await AzureStorage.UploadFileAsync(ContainerType.condo, stream, filePath + fileName);

                if (!string.IsNullOrEmpty(fileUpload))
                {
                    var file = new FileRequest
                    {
                        filePath    = fileUpload,
                        fileName    = fileName,
                        description = fileName,
                        visibility  = true
                    };
                    this.isBusy = true;
                    var result = await service.InsertFile(App.Current.Properties["defaultPid"].ToString(), folderID, file);

                    isBusy = false;
                    newButton.IsEnabled = true;
                    if (result != null)
                    {
                        await LoadFiles(folderID);

                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            return(false);
        }
        public async Task <bool> UpdateData()
        {
            Debug.WriteLine("current page index ---- " + carouselView.Position.ToString());
            switch (carouselView.Position)
            {
            case 0:
                var result = new BaseResponse();

                if (string.IsNullOrEmpty(profileInfoView.portfolioUrlName) || string.IsNullOrEmpty(profileInfoView.name) || string.IsNullOrEmpty(profileInfoView.generalEnquiryContact) || string.IsNullOrEmpty(profileInfoView.maintenanceContact))
                {
                    await DisplayAlert(Config.AllFieldsReqTitle, Config.EmptyValidationMsg, "OK");
                }
                else if (Utils.IsAlaphabetContained(profileInfoView.generalEnquiryContact) || Utils.IsAlaphabetContained(profileInfoView.maintenanceContact))
                {
                    await DisplayAlert("Error", "Contact numbers cannot contain invalid characters.", "OK");
                }
                else
                {
                    var portfolioInfo = new PortfolioInfoRequest
                    {
                        name = profileInfoView.name,
                        generalEnquiryContact = profileInfoView.generalEnquiryContact,
                        maintenanceContact    = profileInfoView.maintenanceContact,
                    };
                    if (profileInfoView.newImage != null)
                    {
                        string filePath = App.Current.Properties["defaultPid"].ToString() + "/images/wallpaper/";
                        var    name     = Guid.NewGuid().ToString();
                        portfolioInfo.image = await AzureStorage.UploadFileAsync(ContainerType.condo, profileInfoView.newImage, filePath + name);
                    }
                    if (profileInfoView.newLogo != null)
                    {
                        string filePath = App.Current.Properties["defaultPid"].ToString() + "/images/logo/";
                        var    name     = Guid.NewGuid().ToString();
                        portfolioInfo.portfolioLogo = await AzureStorage.UploadFileAsync(ContainerType.condo, profileInfoView.newLogo, filePath + name);
                    }
                    result = await service.PutPortfolioInfo(App.Current.Properties["defaultPid"].ToString(), portfolioInfo);

                    if (result != null)
                    {
                        if (result.status_code == System.Net.HttpStatusCode.OK)
                        {
                            await DisplayAlert("Success", Config.SuccessfulSaveMsg, "OK");

                            await Navigation.PopAsync();

                            return(true);
                        }
                        else
                        {
                            await DisplayAlert("Error", result.message, "OK");

                            return(false);
                        }
                    }
                }
                break;

            case 1:

                break;

            case 2:
                break;

            case 3:

                var customizationResult = await service.UpdateCustomization(App.Current.Properties["defaultPid"].ToString(), customizationView.data);

                if (customizationResult != null)
                {
                    if (customizationResult.status_code == System.Net.HttpStatusCode.OK)
                    {
                        await Navigation.PopAsync();
                    }
                    else
                    {
                        await DisplayAlert("Error", customizationResult.message, "OK");
                    }
                }
                break;
            }
            return(false);
        }
Ejemplo n.º 3
0
        async void AddNew(object sender, System.EventArgs e)
        {
            if (string.IsNullOrEmpty(folderID))
            {
                var promptConfig = new PromptConfig
                {
                    Text          = "New Folder",
                    OnTextChanged = args =>
                    {
                        args.IsValid = true;                         // setting this to false will disable the OK/Positive button
                    }
                };
                PromptResult dialog = await UserDialogs.Instance.PromptAsync(promptConfig);

                if (dialog.Ok)
                {
                    var folder = new FolderRequest
                    {
                        categoryName = dialog.Value,
                        visibility   = true
                    };
                    var result = service.InsertFolder(App.Current.Properties["defaultPid"].ToString(), folder);
                    if (result != null)
                    {
                        await LoadFolder();
                    }
                }
            }
            else
            {
                try
                {
                    var picker = await CrossFilePicker.Current.PickFile();

                    var    byteArray = picker.DataArray;
                    string filePath  = App.Current.Properties["defaultPid"].ToString() + "/files/upload/";
                    var    name      = picker.FileName;
                    this.isBusy         = true;
                    newButton.IsEnabled = false;
                    var fileUpload = await AzureStorage.UploadFileAsync(ContainerType.condo, new MemoryStream(byteArray), filePath + name);

                    if (!string.IsNullOrEmpty(fileUpload))
                    {
                        var file = new FileRequest
                        {
                            filePath    = fileUpload,
                            fileName    = name,
                            visibility  = true,
                            description = name,
                        };

                        var result = await service.InsertFile(App.Current.Properties["defaultPid"].ToString(), folderID, file);

                        if (result != null)
                        {
                            if (result.status_code == System.Net.HttpStatusCode.Created)
                            {
                                await LoadFiles(folderID);
                            }
                            else
                            {
                                await DisplayAlert("Error", result.message, "OK");
                            }
                        }
                        else
                        {
                            await DisplayAlert("Error", Config.CommonErrorMsg, "OK");
                        }

                        newButton.IsEnabled = true;
                    }
                    this.isBusy = false;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }
        }
Ejemplo n.º 4
0
        async void Publish(object sender, System.EventArgs e)
        {
            if (startDatePicker.Date > endDatePicker.Date)
            {
                await DisplayAlert("Error", Config.DateValidatinMsg, "OK");

                return;
            }
            string filePath = App.Current.Properties["defaultPid"].ToString() + "/files/upload/";

            var    name     = Guid.NewGuid().ToString();
            string fileName = "";

            if (imageStream != null)
            {
                this.isBusy = true;
                fileName    = await AzureStorage.UploadFileAsync(ContainerType.condo, imageStream, filePath + name);

                this.isBusy = false;
                if (string.IsNullOrEmpty(fileName))
                {
                    await DisplayAlert("Error", "File uploading failed", "OK");

                    return;
                }
            }

            List <BlockItem> blockList = new List <BlockItem>();

            blockList.Clear();
            foreach (var item in collection)
            {
                if (item.isSelected)
                {
                    blockList.Add(new BlockItem()
                    {
                        blockNo = item.blockNo
                    });
                }
            }

            NewsRequest news = new NewsRequest()
            {
                title              = titleText.Text,
                message            = bodyText.Text,
                visibility         = userGroupList[userSegment.SelectedSegment],
                effectiveStartDate = startDatePicker.Date.Year + "-" + startDatePicker.Date.Month + "-" + startDatePicker.Date.Day,
                effectiveEndDate   = endDatePicker.Date.Year + "-" + endDatePicker.Date.Month + "-" + endDatePicker.Date.Day,
                imagePath          = fileName,
                notiGenerated      = notificationSwitch.IsToggled,
                blockList          = blockList
            };

            this.isBusy = true;
            var res = await service.InsertNews(App.Current.Properties["defaultPid"].ToString(), news);

            this.isBusy = false;
            if (res != null)
            {
                if (res.status_code == System.Net.HttpStatusCode.Created)
                {
                    await DisplayAlert("Success", "The news has been successfully published!", "OK");

                    if (!isFromList)
                    {
                        await Navigation.PushAsync(new NewsPage());
                    }
                    else
                    {
                        await Navigation.PopAsync(true);
                    }
                }
                else
                {
                    await DisplayAlert("Error", res.message, "OK");
                }
            }
            else
            {
                await DisplayAlert("Error", Config.CommonErrorMsg, "OK");
            }
        }
Ejemplo n.º 5
0
        async void SaveData(object sender, System.EventArgs e)
        {
            var result = new Facility();

            Debug.WriteLine("current page index ---- " + carouselView.Position.ToString());
            FacilityRequest facilityRequest = new FacilityRequest();

            List <FacilityTimeSlot> updatedSlots = new List <FacilityTimeSlot>();
            FacilityOtherSetting    otherSetting = new FacilityOtherSetting();

            Debug.WriteLine(rulesView.allow_Consecutive.ToString());
            if (infoView.inOperationStart > infoView.inOperationEnd)
            {
                await DisplayAlert("Error", Config.DateValidatinMsg, "OK");

                return;
            }
            if (!Utils.IsValidEmail(infoView.email) || Utils.IsAlaphabetContained(infoView.fax))
            {
                await DisplayAlert(Config.InvalidEmailFormatTitle, Config.InvalidEmailFormatMsg, "OK");

                return;
            }
            Debug.WriteLine("infoviewtype" + infoView.type.ToString());

            if (infoView.inOperationStart.Date > infoView.inOperationEnd.Date)
            {
                await DisplayAlert("Error", "The Operation Start date cannot be later than the Operation End Date.", "OK");

                return;
            }

            facilityRequest = new FacilityRequest
            {
                name          = infoView.name,
                description   = infoView.description,
                equipment     = infoView.equipment,
                capacity      = infoView.capacity,
                deposit       = Convert.ToInt32(infoView.deposit),
                contactPerson = infoView.contactPerson,
                contactNumber = infoView.phone,
                contactFax    = infoView.fax,
                contactEmail  = infoView.email,
                guideLines    = infoView.terms,
                status        = true,
                effectiveDate = infoView.inOperationStart.Date.ToString(),
                endDate       = infoView.inOperationEnd.Date.ToString(),
                photo         = infoView.photo
            };

            if (infoView.newPhoto != null)
            {
                string filePath = App.Current.Properties["defaultPid"].ToString() + "images/facility/";
                var    name     = Guid.NewGuid().ToString();
                facilityRequest.photo = await AzureStorage.UploadFileAsync(ContainerType.condo, infoView.newPhoto, filePath + name);
            }
            if (infoView.type > 0)
            {
                facilityRequest.type = typeList[infoView.type];
            }


            if (slotView.tFacilityTimeSlots != null)
            {
                foreach (var item in slotView.tFacilityTimeSlots)
                {
                    foreach (var detailItem in item.obscollection)
                    {
                        if (DateTime.Parse(detailItem.startTime) > DateTime.Parse(detailItem.endTime))
                        {
                            await DisplayAlert("Error", Config.DateValidatinMsg, "OK");

                            return;
                        }
                        updatedSlots.Add(detailItem);
                    }
                }
            }
            facilityRequest.tFacilityTimeSlots = updatedSlots;

            otherSetting = new FacilityOtherSetting
            {
                advance_Booking_Min        = rulesView.advance_Booking_Min,
                advance_Booking_Max        = rulesView.advance_Booking_Max,
                cancel_Booking             = rulesView.cancel_Booking,
                advance_Booking_MinType    = rulesView.advance_Booking_MinType.Substring(0, 1).ToLower(),
                advance_Booking_MaxType    = rulesView.advance_Booking_MaxType.Substring(0, 1).ToLower(),
                cancel_BookingType         = rulesView.cancel_BookingType.Substring(0, 1).ToLower(),
                max_BookingWithinGrp       = rulesView.max_BookingWithinGrp,
                enable_Max_Booking         = rulesView.enable_Max_Booking,
                max_Prime_BookingWithinGrp = rulesView.max_Prime_BookingWithinGrp,
                max_Booking           = rulesView.max_Booking,
                max_BookingType       = rulesView.max_BookingType.Substring(0, 1).ToLower(),
                max_Prime_Booking     = rulesView.max_Prime_Booking,
                max_Prime_BookingType = rulesView.max_Prime_BookingType.Substring(0, 1).ToLower(),
                slot_Limit            = rulesView.slot_Limit,
                allow_Consecutive     = rulesView.allow_Consecutive,
                booking_SameType      = rulesView.booking_SameType,
                booking_Same          = rulesView.booking_Same,
                booking_SameWithinGrp = rulesView.booking_SameWithinGrp,
                auto_Cancellation     = rulesView.auto_Cancellation,
                auto_CancellationType = rulesView.auto_CancellationType.Substring(0, 1).ToLower()
            };

            facilityRequest.tFacilityOtherSetting = otherSetting;

            if (updateMode)
            {
                result = await service.UpdateFacility(App.Current.Properties["defaultPid"].ToString(), facilityRequest, facilityID);
            }
            else
            {
                result = await service.InsertFacility(App.Current.Properties["defaultPid"].ToString(), facilityRequest);
            }
            if (result != null)
            {
                if (result.status_code == System.Net.HttpStatusCode.OK)
                {
                    await DisplayAlert("Success", Config.SuccessfulSaveMsg, "OK");

                    await Navigation.PopAsync();
                }
                else
                {
                    await DisplayAlert("Error", result.message, "OK");
                }
            }
        }