Exemplo n.º 1
0
        /// <summary>Function for SelectCongNhanCommand.</summary>
        /// <Modified>
        /// Name     Date         Comments
        /// quangnt2  16/03/2020   created
        /// </Modified>
        private async Task SelectCongNhan(CongNhanViewModel congnhan)
        {
            if (congnhan == null)
            {
                return;
            }

            Selected = null;
            await _pageService.PushAsync(new FormCongNhan(congnhan));
        }
Exemplo n.º 2
0
        /// <summary>Function for DeleteCongNhanCommand.</summary>
        /// <Modified>
        /// Name     Date         Comments
        /// quangnt2  16/03/2020   created
        /// </Modified>
        private async Task DeleteCongNhan(CongNhanViewModel congnhanModel)
        {
            if (congnhanModel != null)
            {
                if (await _pageService.DisplayAlert("Cảnh báo", $"Bạn có chắc chắn muốn xóa công nhân {congnhanModel.Name}.", "Đồng ý", "Không"))
                {
                    CongNhans.Remove(congnhanModel);

                    var congnhan = await _congnhanService.GetCongNhan(congnhanModel.Id);

                    await _congnhanService.DeleteCongNhan(congnhan);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>Initializes service, Command.</summary>
        /// <param name="viewModel">The view model.</param>
        /// <param name="congNhanService">The cong nhan service.</param>
        /// <param name="pageService">The page service.</param>
        /// <exception cref="ArgumentNullException">viewModel</exception>
        /// <Modified>
        /// Name     Date         Comments
        /// quangnt2  16/03/2020   created
        /// </Modified>
        public FormCongNhanViewModel(CongNhanViewModel viewModel, ICongNhanService congNhanService, IPageService pageService)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            _pageService     = pageService;
            _congnhanService = congNhanService;

            SaveCommand = new Command(async() => await Save());

            CongNhan = new CongNhan()
            {
                ID      = viewModel.Id,
                Name    = viewModel.Name,
                Address = viewModel.Address,
                Phone   = viewModel.Phone,
                Hobbit  = viewModel.Hobbit,
                Birth   = viewModel.Id > 0 ? viewModel.Birth : DateTime.Now,
                Gender  = viewModel.Gender
            };
        }