Esempio n. 1
0
        public IActionResult Update(string id, [FromBody] ContractorViewModel cvm)
        {
            if (cvm != null)
            {
                // find contractor with the given ID
                var contractor = DbContext.Contractor.Where(i => i.ID == id).FirstOrDefault();

                if (contractor != null)
                {
                    // handle the update
                    contractor.Name            = cvm.Name;
                    contractor.Nip             = cvm.Nip;
                    contractor.Street          = cvm.Street;
                    contractor.Number          = cvm.Number;
                    contractor.ApartmentNumber = cvm.ApartmentNumber;
                    contractor.ZipCode         = cvm.ZipCode;
                    contractor.City            = cvm.City;
                    contractor.PersonToInvoice = cvm.PersonToInvoice;

                    // override all properties that could be set from server-side only
                    contractor.ModifyDate = DateTime.Now;

                    //save the changes into the db
                    DbContext.SaveChanges();

                    //return updated Contractor to the client
                    return(new JsonResult(TinyMapper.Map <ContractorViewModel>(contractor), DefaultJsonSettings));
                }
            }
            //return a HTTP Status 404 (Not Found) if contractor has not been found
            return(NotFound(new { Error = String.Format("Contractor ID {0} not found", id) }));
        }
Esempio n. 2
0
        public ActionResult Create(ContractorViewModel contractor)
        {
            if (contractor == null)
            {
                throw new ArgumentNullException(nameof(contractor));
            }

            Log.Debug("Test debug message");

            using (var context = new VatplanEntities())
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        // TODO: Add insert logic here
                        context.Contractors.Add(contractor.ToDTO());
                        context.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                }
                catch (Exception ex)
                {
                    Log.Debug("Saving model error", ex);
                }
                return(View());
            }
        }
Esempio n. 3
0
        Contractor GetModelDatas(ContractorViewModel _viewModel)
        {
            Contractor _model = new Contractor()
            {
                ContractorID                    = _viewModel.ContractorID,
                DeviceID                        = _viewModel.DeviceID,
                OwnershipType                   = _viewModel.OwnershipType.ToString(),
                Company                         = _viewModel.Company,
                SurnameContractPers             = _viewModel.SurnameContractPers,
                NameContractPers                = _viewModel.NameContractPers,
                PatronymicContractPers          = _viewModel.PatronymicContractPers,
                PositionContractPers            = _viewModel.PositionContractPers,
                DepartmentContractPers          = _viewModel.DepartmentContractPers,
                OfficeAdressCompanyContractPers = _viewModel.OfficeAdressCompanyContractPers,
                StockAdressCompanyContractPers  = _viewModel.StockAdressCompanyContractPers,
                PhoneContractPers               = _viewModel.PhoneContractPers,
                InternalPnoneContractPers       = _viewModel.InternalPnoneContractPers,
                MobilePhoneContractPers         = _viewModel.MobilePhoneContractPers,
                EmailContractPers               = _viewModel.EmailContractPers,
                SiteCompanyContractPers         = _viewModel.SiteCompanyContractPers,
                NoteContractor                  = _viewModel.NoteContractor,
                CreateDateTime                  = _viewModel.CreateDateTime,
                ChangeDateTime                  = _viewModel.ChangeDateTime
            };

            return(_model);
        }
        // GET: Contractors/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Contractor contractor = db.Contractors.Find(id);

            if (contractor == null)
            {
                return(HttpNotFound());
            }
            ContractorViewModel model;

            model = new ContractorViewModel
            {
                Id      = contractor.Id,
                Name    = contractor.Name,
                Phone   = contractor.Phone,
                Email   = contractor.Email,
                Address = contractor.Address,
                DeptId  = contractor.DeptId,
                Status  = contractor.Status
            };
            ViewBag.DepartmentsList = db.Departments.ToList();
            return(View(model));
        }
        // GET: Contracts
        public ActionResult List(int page = 1)
        {
            ContractorViewModel viewModel = new ContractorViewModel();

            try
            {
                viewModel.PagingInfo = new PagingInfo
                {
                    TotalRecordsCount = contractService.TotalRecordsCount(),
                    RecordsPerPage    = RecordsPerPage,
                    CurentPageNo      = page
                };

                if (viewModel.PagingInfo.TotalRecordsCount > 0)
                {
                    viewModel.Contractors = GetAllContractors(page);
                }
                else
                {
                    DisplayWarningMessage("There are no Contractors to display");
                }
            }
            catch (Exception exp)
            {
                DisplayLoadErrorMessage(exp);
            }

            return(View(viewModel));
        }
Esempio n. 6
0
        public ActionResult Edit([Bind(Include = "Id,Name,FullName,INN,OKPO,VATNumber,CountryOfRegistration,TypeOfCounterparty,Street,House,Flat,District,Region,City,Country,PostalCode,StringRepresentedAddress,IsBranch,HeadContractor,BranchCode")] ContractorViewModel contractor)
        {
            if (ModelState.IsValid)
            {
                unitOfWork.ContractorViewModel.AddOrUpdate(contractor, User.Identity.GetUserName());
                unitOfWork.Save();

                return(RedirectToAction("Index"));
            }
            return(View(contractor));
        }
Esempio n. 7
0
        public ActionResult Edit(ContractorViewModel _viewModel)
        {
            if (ModelState.IsValid)
            {
                var _model = GetModelDatas(_viewModel);
                db.Entry(_model).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            //ViewBag.DeviceID = new SelectList(db.Devices, "DeviceID", "InventoryNumber", _viewModel.DeviceID);

            return(View(_viewModel));
        }
Esempio n. 8
0
        // GET: Contractors/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ContractorViewModel contractor = unitOfWork.ContractorViewModel.Get((Guid)id);

            if (contractor == null)
            {
                return(HttpNotFound());
            }
            return(View(contractor));
        }
Esempio n. 9
0
        public ActionResult Index()
        {
            //return View(db.Contractors.ToList());
            #region List
            var _model     = db.Contractors.Include(d => d.Devices);
            var _viewModel = new List <ContractorViewModel>();

            foreach (var item in _model)
            {
                _viewModel.Add(ContractorViewModel.GetViewModelDatas(item));
            }

            return(View(_viewModel));

            #endregion // end of List
        }
Esempio n. 10
0
        public ActionResult Select(ContractorViewModel model)
        {
            var error = "";

            if (model.errors == null)
            {
                model.errors = new List <string>();
            }

            if (!_contractorService.SetContractorForRequest(out error, model.SelectedContractorId, model.RequestId, model.Comment))
            {
                model.errors.Add(error);
                return(View(model));
            }
            return(RedirectToAction("Index", "Request"));
        }
Esempio n. 11
0
        public async Task <IActionResult> Create([Bind("CompanyId")] ContractorViewModel contractor)
        {
            if (ModelState.IsValid)
            {
                var        company     = _context.Company.Find(contractor.CompanyId);
                Contractor contractor1 = new Contractor {
                    Company = company
                };
                company.Contractor = contractor1;
                _context.Add(contractor1);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            // ViewData["ContractorId"] = new SelectList(_context.Company, "id", "id", contractor.ContractorId);
            return(View(contractor));
        }
Esempio n. 12
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Contractor _model     = db.Contractors.Find(id);
            var        _viewModel = ContractorViewModel.GetViewModelDatas(_model);

            if (_model == null)
            {
                return(HttpNotFound());
            }
            //ViewBag.DeviceID = new SelectList(db.Devices, "DeviceID", "InventoryNumber", _model.DeviceID);

            return(View(_viewModel));
        }
 public ActionResult Create(ContractorViewModel model)
 {
     if (ModelState.IsValid)
     {
         Contractor cont = new Contractor();
         cont.Name    = model.Name;
         cont.Phone   = model.Phone;
         cont.Email   = model.Email;
         cont.Address = model.Address;
         cont.DeptId  = model.DeptId;
         cont.Status  = model.Status;
         db.Contractors.Add(cont);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartmentsList = db.Departments.ToList();
     return(View(model));
 }
Esempio n. 14
0
        // GET: Contractors/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ContractorViewModel contractor = unitOfWork.ContractorViewModel.Get((Guid)id);

            if (contractor == null)
            {
                return(HttpNotFound());
            }

            ViewResult view = View(contractor);

            view.ViewBag.HistoryList = unitOfWork.HistoryViewModel.GetAllBySubject((Guid)id);
            return(view);
        }
 public ActionResult Edit(ContractorViewModel model)
 {
     if (ModelState.IsValid)
     {
         Contractor consul = new Contractor();
         consul.Id              = model.Id;
         consul.Name            = model.Name;
         consul.Phone           = model.Phone;
         consul.Email           = model.Email;
         consul.Address         = model.Address;
         consul.DeptId          = model.DeptId;
         consul.Status          = model.Status;
         db.Entry(consul).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartmentsList = db.Departments.ToList();
     return(View(model));
 }
Esempio n. 16
0
 public static void ContractorToContractorViewModel(Contractor contractor, out ContractorViewModel contractorVM)
 {
     contractorVM = new ContractorViewModel();
     if (contractor != null)
     {
         contractorVM.Id                       = contractor.Id;
         contractorVM.Name                     = contractor.Name;
         contractorVM.FullName                 = contractor.FullName;
         contractorVM.INN                      = contractor.INN;
         contractorVM.OKPO                     = contractor.OKPO;
         contractorVM.VATNumber                = contractor.VATNumber;
         contractorVM.CountryOfRegistration    = contractor.CountryOfRegistration;
         contractorVM.Street                   = contractor.Address.Street;
         contractorVM.House                    = contractor.Address.House;
         contractorVM.Flat                     = contractor.Address.Flat;
         contractorVM.City                     = contractor.Address.City;
         contractorVM.District                 = contractor.Address.District;
         contractorVM.Region                   = contractor.Address.Region;
         contractorVM.Country                  = contractor.Address.Country;
         contractorVM.StringRepresentedAddress = contractor.Address.StringRepresentedAddress;
     }
 }
Esempio n. 17
0
        public IActionResult Add([FromBody] ContractorViewModel cvm)
        {
            if (cvm != null)
            {
                // create a new Contractor with the client-sent json data
                var newContractor = TinyMapper.Map <Contractor>(cvm);

                // override any property that could be set from server-side only
                newContractor.ID         = Guid.NewGuid().ToString();
                newContractor.CreateDate = DateTime.Now;

                //add the new contractor
                DbContext.Contractor.Add(newContractor);

                //save the changes into the db
                DbContext.SaveChanges();

                //return created Contractor to the clinet
                return(new JsonResult(TinyMapper.Map <ContractorViewModel>(newContractor), DefaultJsonSettings));
            }
            // return a generic HTTP Status 500 (Not Found) if the client request is invalid.
            return(new StatusCodeResult(500));
        }
Esempio n. 18
0
        public ActionResult Create(ContractorViewModel contractorViewModel)
        {
            try
            {
                var contractor = _mapper.Map <Contractor>(contractorViewModel);
                contractor.Id = Guid.NewGuid();
                _contractorService.AddContractor(contractor);

                return(RedirectToAction("Index"));
            }
            catch (ContractorNotValidException ex)
            {
                // log error, for demo show in debug output
                Debug.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                // log error, for demo show in debug output
                Debug.WriteLine(ex.Message);
            }

            return(View());
        }
Esempio n. 19
0
        public ActionResult Edit(ContractorViewModel contractorViewModel)
        {
            try
            {
                Guard.ThrowIfArgumentIsNull(contractorViewModel, nameof(contractorViewModel));

                var contractor = _mapper.Map <Contractor>(contractorViewModel);
                _contractorService.UpdateContractor(contractor);

                return(RedirectToAction("Index"));
            }
            catch (ArgumentNullException ex)
            {
                // log error, for demo show in debug output
                Debug.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                // log error, for demo show in debug output
                Debug.WriteLine(ex.Message);
            }

            return(View());
        }
Esempio n. 20
0
        public ActionResult Delete(Guid id, ContractorViewModel contractorViewModel)
        {
            try
            {
                Guard.ThrowIfArgumentIsNull(id, nameof(id));

                var contractor = _contractorService.GetById(id);
                _contractorService.DeleteContractor(contractor);

                return(RedirectToAction("Index"));
            }
            catch (ArgumentNullException ex)
            {
                // log error, for demo show in debug output
                Debug.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                // log error, for demo show in debug output
                Debug.WriteLine(ex.Message);
            }

            return(View());
        }
Esempio n. 21
0
 public NewContractorView()
 {
     InitializeComponent();
     DataContext = new ContractorViewModel();
 }
Esempio n. 22
0
        public StackLayout AssignValues()
        {
            BindingContext = new ContractorViewModel();
            var label = new Label
            {
                Text            = "Refer a contractor",
                BackgroundColor = Color.Black,
                Font            = Font.SystemFontOfSize(NamedSize.Large),
                TextColor       = Color.White,
                VerticalOptions = LayoutOptions.Center,
                XAlign          = TextAlignment.Center,        // Center the text in the blue box.
                YAlign          = TextAlignment.Center,        // Center the text in the blue box.
            };

            var firstNameLabel = new Label {
                HorizontalOptions = LayoutOptions.Fill
            };

            firstNameLabel.Text = "First Name";

            var firstName = new MyEntry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            firstName.SetBinding(MyEntry.TextProperty, ContractorViewModel.ContractorFirstNamePropertyName);

            var lastNameLabel = new Label {
                HorizontalOptions = LayoutOptions.Fill
            };

            lastNameLabel.Text = "Last Name";

            var lastName = new MyEntry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            lastName.SetBinding(MyEntry.TextProperty, ContractorViewModel.ContractorLastNamePropertyName);

            var phoneNoLabel = new Label {
                HorizontalOptions = LayoutOptions.Fill
            };

            phoneNoLabel.Text = "Phone";

            var phoneNo = new Entry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            phoneNo.SetBinding(Entry.TextProperty, ContractorViewModel.ContractorPhonePropertyName);
            phoneNo.Keyboard = Keyboard.Telephone;

            var emailLabel = new Label {
                HorizontalOptions = LayoutOptions.Fill
            };

            emailLabel.Text = "Email";

            var email = new Entry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            email.SetBinding(Entry.TextProperty, ContractorViewModel.ContractorEmailPropertyName);
            email.Keyboard = Keyboard.Email;

            var additionalInfoLabel = new Label {
                HorizontalOptions = LayoutOptions.Fill
            };

            additionalInfoLabel.Text = "Additional Information";

            var additionalInfo = new MyEntry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            additionalInfo.SetBinding(MyEntry.TextProperty, ContractorViewModel.ContractorAdditionalInfoPropertyName);

            var chkInvite = new CheckBox();

            chkInvite.SetBinding(CheckBox.CheckedProperty, ContractorViewModel.isCheckedPropertyName, BindingMode.TwoWay);
            chkInvite.DefaultText = "I Agree to the terms and condition";

            Button btnSubmitContractor = new Button
            {
                HorizontalOptions = LayoutOptions.Fill,
                BackgroundColor   = Color.FromHex("22498a"),
                Text = "Submit"
            };

            btnSubmitContractor.SetBinding(Button.CommandProperty, ContractorViewModel.SubmitCommandPropertyName);

            var downloadButton = new Button {
                Text = "Download Terms and Conditions", BackgroundColor = Color.FromHex("f7941d"), TextColor = Color.White
            };

            downloadButton.Clicked += (object sender, EventArgs e) => {
                DependencyService.Get <FormSample.Helpers.Utility.IUrlService> ().OpenUrl(Utility.PDFURL);
            };

            var contactUsButton = new Button {
                Text = "Contact Us", BackgroundColor = Color.FromHex("0d9c00"), TextColor = Color.White
            };

            contactUsButton.Clicked += (object sender, EventArgs e) =>
            {
                App.RootPage.NavigateTo("Contact us");
            };

            var labelStakeLayout = new StackLayout()
            {
                Children    = { label },
                Orientation = StackOrientation.Vertical
            };

            var cotrolStakeLayout = new StackLayout()
            {
                Padding           = new Thickness(Device.OnPlatform(5, 5, 5), 0, Device.OnPlatform(5, 5, 5), 0),       //new Thickness(5,0,5,0),
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.Fill,
                Orientation       = StackOrientation.Vertical,
                Children          = { firstNameLabel, firstName, lastNameLabel, lastName, phoneNoLabel, phoneNo, emailLabel, email, additionalInfoLabel, additionalInfo, chkInvite }
            };

            var scrollableContentLayout = new ScrollView()
            {
                Content           = cotrolStakeLayout,
                Orientation       = ScrollOrientation.Vertical,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            var buttonLayout = new StackLayout()
            {
                Padding           = new Thickness(Device.OnPlatform(5, 5, 5), 0, Device.OnPlatform(5, 5, 5), 0),       //new Thickness(5,0,5,0),
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Orientation       = StackOrientation.Vertical,
                Children          = { btnSubmitContractor, downloadButton, contactUsButton }
            };

            var nameLayout = new StackLayout()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Orientation       = StackOrientation.Vertical,
                Children          = { labelStakeLayout, scrollableContentLayout, buttonLayout }
            };

            return(new StackLayout {
                Children = { nameLayout }
            });
        }
Esempio n. 23
0
        public ViewResult Select(int id)
        {
            var model = new ContractorViewModel();

            model.errors = new List <string>();
            var error   = "";
            var request = new DtoRequest();

            if (!_requestService.GetRequestById(id, out request, out error))
            {
                model.errors.Add(error);
            }

            model.RequestId = request.Id;
            model.Mileage   = request.Mileage;

            int?DeparturePointId = null;

            if (request.DeparturePointId != null)
            {
                DeparturePointId       = request.DeparturePointId;
                model.DepartureAddress = _locationService.GetPOIById((int)DeparturePointId).Name;
            }
            else
            {
                model.DepartureAddress = request.DepartureAddress;
            }


            int?DestinationPointId = null;

            if (request.DestinationPointId != null)
            {
                DestinationPointId       = request.DestinationPointId;
                model.DestinationAddress = _locationService.GetPOIById((int)DestinationPointId).Name;
            }
            else
            {
                model.DestinationAddress = request.DestinationAddress;
            }


            model.contractors = _contractorService.GetAllContractors();

            if (model.contractors == null || model.contractors.Count == 0)
            {
                model.errors.Add("Не найдено подходящих вариантов для данной поездки");
            }

            var requestPriceCalculator = new RequestPriceCalculatingServiceClient();

            // заполняем цену поездки для каждого подрядчика
            foreach (var contractor in model.contractors)
            {
                contractor.TotalPrice = /*(decimal)model.Mileage * contractor.Tariff;*/ requestPriceCalculator.CalculateRequestPrice(model.Mileage, contractor.Tariff);
            }

            requestPriceCalculator.Close();

            return(View(model));
        }
Esempio n. 24
0
        public MyContractorPage()
        {
            BindingContext      = new ContractorViewModel();
            progressService     = DependencyService.Get <IProgressService> ();
            contractorViewModel = new ContractorViewModel();
            counter             = 1;

            var label = new Label {
                Text            = "My contractor", BackgroundColor = Color.Black, Font = Font.SystemFontOfSize(NamedSize.Large),
                TextColor       = Color.White,
                VerticalOptions = LayoutOptions.Center,
                XAlign          = TextAlignment.Center,        // Center the text in the blue box.
                YAlign          = TextAlignment.Center
            };



            listView = new ListView
            {
                RowHeight = 40
            };
            var grid = new Grid
            {
                ColumnSpacing = 100
            };

            grid.Children.Add(new Label {
                Text = "Contractor", TextColor = Color.Red
            }, 0, 0);                                                                                    // Left, First element
            grid.Children.Add(new Label {
                Text = "Date refered", TextColor = Color.Red
            }, 1, 0);

            //TODO clear all contractor
            var btnClearAllContractor = new Button {
                Text = "Clear all contractor", BackgroundColor = Color.FromHex("3b73b9"), TextColor = Color.White
            };

            btnClearAllContractor.SetBinding(Button.CommandProperty, ContractorViewModel.GotoDeleteAllContractorCommandPropertyName);

            var downloadButton = new Button {
                Text = "Download Terms and Conditions", BackgroundColor = Color.FromHex("f7941d"), TextColor = Color.White
            };

            downloadButton.Clicked += (object sender, EventArgs e) => {
                DependencyService.Get <FormSample.Helpers.Utility.IUrlService> ().OpenUrl(Utility.PDFURL);
            };

            var contactUsButton = new Button {
                Text = "Contact Us", BackgroundColor = Color.FromHex("0d9c00"), TextColor = Color.White
            };

            contactUsButton.Clicked += delegate
            {
                App.RootPage.NavigateTo("Contact us");
            };

            var labelStakeLayout = new StackLayout()
            {
                Children = { label }
            };

            var controlStakeLayout = new StackLayout()
            {
                Orientation     = StackOrientation.Vertical,
                Padding         = new Thickness(Device.OnPlatform(5, 5, 5), 0, Device.OnPlatform(5, 5, 5), 0),         //new Thickness(5,0,5,0),
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        = { grid, listView }
            };

            var buttonLayout = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(Device.OnPlatform(5, 5, 5), 0, Device.OnPlatform(5, 5, 5), 0),             //new Thickness(5,0,5,0),
                Children    = { btnClearAllContractor, downloadButton, contactUsButton }
            };

            var nameLayOut = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        = { labelStakeLayout, controlStakeLayout, buttonLayout }
            };

            Content = new StackLayout
            {
                Children = { nameLayOut }
            };

            listView.ItemTapped += async(sender, args) =>
            {
                var contractor = args.Item as Contractor;
                if (contractor == null)
                {
                    return;
                }
                var answer = await DisplayAlert("Confirm", "Do you wish to clear this item", "Yes", "No");

                if (answer)
                {
                    progressService.Show();
                    var result = await dataService.DeleteContractor(contractor.Id, Settings.GeneralSettings);

                    if (result != null)
                    {
                        await this.contractorViewModel.DeleteContractor(contractor.Id);

                        progressService.Dismiss();
                        listView.ItemsSource = this.contractorViewModel.contractorList;
                    }
                }

                listView.SelectedItem = null;
            };
        }
Esempio n. 25
0
        public ScrollView AssignValues()
        {
            // BindingContext = new ContractorViewModel(Navigation);
            BindingContext = new ContractorViewModel();
            var label = new Label
            {
                Text            = "Refer a contractor",
                Font            = Font.SystemFontOfSize(NamedSize.Medium),
                TextColor       = Color.White,
                VerticalOptions = LayoutOptions.Center,
                XAlign          = TextAlignment.Center, // Center the text in the blue box.
                YAlign          = TextAlignment.Center  // Center the text in the blue box.
            };

            var firstNameLabel = new Label {
                HorizontalOptions = LayoutOptions.Fill
            };

            firstNameLabel.Text = "First Name";

            var firstName = new Entry {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            firstName.SetBinding(Entry.TextProperty, ContractorViewModel.ContractorFirstNamePropertyName);
            //firstName.Text = contractor.FirstName;

            var lastNameLabel = new Label {
                HorizontalOptions = LayoutOptions.Fill
            };

            lastNameLabel.Text = "Last Name";

            var lastName = new Entry {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            lastName.SetBinding(Entry.TextProperty, ContractorViewModel.ContractorLastNamePropertyName);
            //lastName.Text = contractor.LastName;

            var phoneNoLabel = new Label {
                HorizontalOptions = LayoutOptions.Fill
            };

            phoneNoLabel.Text = "Phone";

            var phoneNo = new Entry {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            phoneNo.SetBinding(Entry.TextProperty, ContractorViewModel.ContractorPhonePropertyName);
            phoneNo.Keyboard = Keyboard.Telephone;
            //phoneNo.Text = contractor.Phone;

            var emailLabel = new Label {
                HorizontalOptions = LayoutOptions.Fill
            };

            emailLabel.Text = "Email";

            var email = new Entry {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            email.SetBinding(Entry.TextProperty, ContractorViewModel.ContractorEmailPropertyName);
            email.Keyboard = Keyboard.Email;
            //email.Text = contractor.Email;

            var additionalInfoLabel = new Label {
                HorizontalOptions = LayoutOptions.Fill
            };

            additionalInfoLabel.Text = "Additional Information";

            var additionalInfo = new Entry {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            additionalInfo.SetBinding(Entry.TextProperty, ContractorViewModel.ContractorAdditionalInfoPropertyName);
            //additionalInfo.Text = contractor.AdditionalInformation;

            var chkInvite = new CheckBox();

            chkInvite.SetBinding(CheckBox.CheckedProperty, ContractorViewModel.isCheckedPropertyName);
            chkInvite.DefaultText = "I Agree to the terms and condition";
            //chkInvite.IsVisible = true;

            Button btnSubmitContractor = new Button
            {
                HorizontalOptions = LayoutOptions.Fill,
                BackgroundColor   = Color.FromHex("22498a"),
                Text = "Submit"
            };

            btnSubmitContractor.SetBinding(Button.CommandProperty, ContractorViewModel.SubmitCommandPropertyName);

            var downloadButton = new Button {
                Text = "Download Terms and Conditions", BackgroundColor = Color.FromHex("f7941d"), TextColor = Color.White
            };
            var contactUsButton = new Button {
                Text = "Contact Us", BackgroundColor = Color.FromHex("0d9c00"), TextColor = Color.White
            };

            var nameLayout = new StackLayout()
            {
                WidthRequest      = 320,
                Padding           = new Thickness(20, 0, 10, 0),
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Orientation       = StackOrientation.Vertical,
                Children          = { label, firstNameLabel, firstName, lastNameLabel, lastName, phoneNoLabel, phoneNo, emailLabel, email, additionalInfoLabel, additionalInfo, chkInvite, btnSubmitContractor, downloadButton, contactUsButton },
                BackgroundColor   = Color.Gray
            };

            return(new ScrollView {
                Content = nameLayout
            });
        }
Esempio n. 26
0
        public MyContractorPage()
        {
            contractorViewModel = new ContractorViewModel();
            counter             = 1;
            BackgroundColor     = Color.White;
            var x = DependencyService.Get <FormSample.Helpers.Utility.INetworkService>().IsReachable();

            if (!x)
            {
                DisplayAlert("Message", "Could not connect to the internet.", "OK");
            }

            var label = new Label {
                Text            = "My contractor", BackgroundColor = Color.Black, Font = Font.SystemFontOfSize(NamedSize.Medium),
                TextColor       = Color.White,
                VerticalOptions = LayoutOptions.Center,
                XAlign          = TextAlignment.Center,        // Center the text in the blue box.
                YAlign          = TextAlignment.Center
            };

            listView = new ListView
            {
                RowHeight = 40
            };
            var grid = new Grid
            {
                ColumnSpacing = 200
            };

            grid.Children.Add(new Label {
                Text = "Contractor", TextColor = Color.Red
            }, 0, 0);                                                                        // Left, First element
            grid.Children.Add(new Label {
                Text = "Date refered", TextColor = Color.Red
            }, 1, 0);

            var btnClearAllContractor = new Button {
                Text = "Clear all contractor", BackgroundColor = Color.FromHex("3b73b9"), TextColor = Color.White
            };

            btnClearAllContractor.SetBinding(Button.CommandProperty, ContractorViewModel.GotoDeleteAllContractorCommandPropertyName);

            var downloadButton = new Button {
                Text = "Download Terms and Conditions", BackgroundColor = Color.FromHex("f7941d"), TextColor = Color.White
            };

            var contactUsButton = new Button {
                Text = "Contact Us", BackgroundColor = Color.FromHex("0d9c00"), TextColor = Color.White
            };

            var nameLayOut = new StackLayout
            {
//                Orientation = StackOrientation.Vertical,
//                Children = { btnClearAllContractor, downloadButton, contactUsButton }
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        = { label, grid, listView, btnClearAllContractor, downloadButton, contactUsButton }
            };

            Content = new ScrollView
            {
                Content = nameLayOut
            };

            listView.ItemTapped += async(sender, args) =>
            {
                var contractor = args.Item as Contractor;
                if (contractor == null)
                {
                    return;
                }

                var answer = await DisplayAlert("Confirm", "Do you wish to clear this item", "Yes", "No");

                if (answer)
                {
                    var result = await dataService.DeleteContractor(contractor.Id, Settings.GeneralSettings);

                    if (result != null)
                    {
                        await this.contractorViewModel.DeleteContractor(contractor.Id);

                        listView.ItemsSource = this.contractorViewModel.contractorList;
                    }
                }

                listView.SelectedItem = null;
            };
        }