Exemplo n.º 1
0
        private void ShowConfirmation(VTSModel vts)
        {
            var alert = new AlertDialog.Builder(this).Create();

            var alertView = LayoutInflater.Inflate(Resource.Layout.confirmationPopup, null);

            alertView.FindViewById <TextView>(Resource.Id.textView2).Text = _vacationsViewModel.Localaizer.Localize("confirmDelete");
            alertView.FindViewById <Button>(Resource.Id.confirmation_popup_cancel_button).Text = _vacationsViewModel.Localaizer.Localize("cancel_button");
            alertView.FindViewById <Button>(Resource.Id.confirmation_popup_ok_button).Text     = _vacationsViewModel.Localaizer.Localize("delButton");
            alertView.FindViewById <TextView>(Resource.Id.textView2).Typeface = FontLoader.GetFontBold(this);
            alertView.FindViewById <Button>(Resource.Id.confirmation_popup_cancel_button).Typeface = FontLoader.GetFontNormal(this);
            alertView.FindViewById <Button>(Resource.Id.confirmation_popup_ok_button).Typeface     = FontLoader.GetFontNormal(this);
            alertView.FindViewById <Button>(Resource.Id.confirmation_popup_cancel_button).Click   += (s, e) =>
            {
                alert.Hide();
                alert.Cancel();
            };
            alertView.FindViewById <Button>(Resource.Id.confirmation_popup_ok_button).Click += async(s, e) =>
            {
                alert.Hide();
                alert.Cancel();
                await Delete(vts);
            };

            alert.SetView(alertView);
            alert.Show();
        }
Exemplo n.º 2
0
        public async Task <bool> DeleteVacation(VacationsViewModel viewModel, VTSModel vacation)
        {
            VacationUpdateResponce responce = new VacationUpdateResponce(0, true, string.Empty);

            if (viewModel.IsOnlineMode)
            {
                try
                {
                    responce = await _vacationsDataService.DeleteVacationInRest(vacation);
                }
                catch (AggregateException e)
                {
                    viewModel.ErrorMessage = e.InnerExceptions[0].Data["message"].ToString();
                    return(false);
                }
                catch (Exception ex)
                {
                    viewModel.ErrorMessage = ex.Message;
                    return(false);
                }
            }
            if (responce.LoginSuccess)
            {
                viewModel.State        = UserState.Authorized;
                viewModel.ErrorMessage = String.Empty;
            }
            else
            {
                viewModel.State        = UserState.Unauthorized;
                viewModel.ErrorMessage = responce.ErrorMessage;
            }
            await _vacationsDataService.DeleteVacationsInSql(vacation);

            return(await Helper.Complete(responce.LoginSuccess));
        }
Exemplo n.º 3
0
 public async Task DeleteVacationsInSql(VTSModel vtsmodel)
 {
     try
     {
         if (sqliteService == null)
         {
             sqliteService = new SQLiteService(_sqlitePlatform, await _fileSystemService.GetPath(_configuration.SqlDatabaseName));
         }
     }
     catch (Exception exp)
     {
         sqliteService = null;
     }
     if (sqliteService != null)
     {
         try
         {
             await sqliteService.Delete <VacationInfoDTO>(vtsmodel.Id.ToString());
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemplo n.º 4
0
        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
        {
            switch (editingStyle)
            {
            case UITableViewCellEditingStyle.Delete:
                // remove the item from the underlying data source
                owner.DeleteItem(tableItems[indexPath.Row]);
                tableItems.RemoveAt(indexPath.Row);
                // delete the row from the table
                tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                break;

            case UITableViewCellEditingStyle.Insert:
                //---- create a new item and add it to our underlying data
                var newItem = new VTSModel();
                newItem.VacationType = "inserted";
                tableItems.Insert(indexPath.Row, newItem);
                //---- insert a new row in the table
                tableView.InsertRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                break;

            case UITableViewCellEditingStyle.None:
                Console.WriteLine("CommitEditingStyle:None called");
                break;
            }
        }
Exemplo n.º 5
0
        public VacationInfoModel ConvertToVacationInfoModel(VTSModel vtsModel)
        {
            VacationInfoModel info = new VacationInfoModel();

            info.Id     = vtsModel.Id;
            info.Status = VacationInfoMockModel.VAC;
            return(info);
        }
Exemplo n.º 6
0
 public async override void DeleteItem(object item)
 {
     if (item != null)
     {
         VTSModel vts = item as VTSModel;
         if (vts != null)
         {
             await FactorySingleton.Factory.Get <VacationsViewModel>().DeleteVacationInfo(vts);
         }
     }
 }
Exemplo n.º 7
0
        public VacationInfoDTO ConvertToVacationInfoDTO(VTSModel vts)
        {
            VacationInfoDTO vacationInfo = new VacationInfoDTO();

            vacationInfo.Id           = vts.Id;
            vacationInfo.Date         = vts.Date;
            vacationInfo.Status       = vts.Status;
            vacationInfo.VacationType = vts.VacationType;
            vacationInfo.ImageSRC     = (vts.ImageSRC == null) ? null : vts.ImageSRC.ToString();
            vacationInfo.Image        = vts.Image;
            return(vacationInfo);
        }
Exemplo n.º 8
0
        private async Task Delete(VTSModel vts)
        {
            var success = await _vacationsViewModel.DeleteVacationInfo(vts);

            if (success)
            {
                LoadListView();
            }
            else
            {
                AlertDialog(_vacationsViewModel.Localaizer.Localize("error") + " " + _vacationsViewModel.ErrorMessage, null);
            }
        }
Exemplo n.º 9
0
        public VTSModel ConvertToVTSModel(VacationInfoDTO vacationInfo)
        {
            VTSModel vts = new VTSModel();

            vts.Id           = vacationInfo.Id;
            vts.Date         = vacationInfo.Date;
            vts.Status       = vacationInfo.Status;
            vts.VacationType = vacationInfo.VacationType;
            vts.Image        = vacationInfo.Image;
            if (vacationInfo.ImageSRC != null)
            {
                vts.ImageSRC = new Uri(vacationInfo.ImageSRC);
            }

            return(vts);
        }
Exemplo n.º 10
0
        public VTSModel ConvertToVTSModel(VacationInfoModel vacationInfo)
        {
            VTSModel vtsModel = new VTSModel();

            vtsModel.Id = vacationInfo.Id;
            if (vacationInfo.Type.Value != null)
            {
                vtsModel.VacationType = vacationInfo.Type.Value;
            }
            vtsModel.StartDate = vacationInfo.StartDate;
            vtsModel.EndDate   = vacationInfo.EndDate;
            var startDate  = LocalizeMonth((new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddMilliseconds(vacationInfo.StartDate).ToLocalTime().ToString("MMM dd, yyyy"));
            var endDate    = LocalizeMonth((new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddMilliseconds(vacationInfo.EndDate).ToLocalTime().ToString("MMM dd, yyyy"));
            var _startDate = ConverterHelper.ConvertMillisecToDateTime(vacationInfo.StartDate);
            var _endDate   = ConverterHelper.ConvertMillisecToDateTime(vacationInfo.EndDate);
            var dayCount   = ConverterHelper.CalculateDuration(_startDate, _endDate);
            var days       = string.Empty;

            if (dayCount == 1)
            {
                days = _localizer.Localize("day");
            }
            else
            {
                if (dayCount > 1 && dayCount < 5)
                {
                    days = _localizer.Localize("day24");
                }
                else
                {
                    days = _localizer.Localize("days");
                }
            }
            vtsModel.Date = startDate + " - " + endDate + " (" + dayCount + " " + days + ")";
            if (vacationInfo.Status != null)
            {
                vtsModel.Status = vacationInfo.Status.Value;
            }

            if (vacationInfo.Type.Value != null)
            {
                vtsModel.VacationType = vacationInfo.Type.Value;
            }
            return(vtsModel);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Called manually when the table goes into edit mode
        /// </summary>
        public void WillBeginTableEditing(UITableView tableView)
        {
            //---- start animations
            tableView.BeginUpdates();

            //---- insert a new row in the table
            tableView.InsertRows(new NSIndexPath[] {
                NSIndexPath.FromRowSection(tableView.NumberOfRowsInSection(0), 0)
            }, UITableViewRowAnimation.Fade);
            //---- create a new item and add it to our underlying data
            var newItem = new VTSModel();

            newItem.VacationType = "(add new)";
            tableItems.Add(newItem);

            //---- end animations
            tableView.EndUpdates();
        }
Exemplo n.º 12
0
        public async Task <VacationUpdateResponce> DeleteVacationInRest(VTSModel vacation)
        {
            string result       = String.Empty;
            bool   loginSuccess = false;

            try
            {
                RestService restService = new RestService(_configuration.RestServerUrl, "Vacations");
                restService.Timeout = _configuration.ServerTimeOut;
                var request = await restService.Delete(vacation.Id);

                loginSuccess = request.IsSuccessStatusCode;
                if (request.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    result = "notFound";
                }
                if (request.StatusCode == System.Net.HttpStatusCode.Forbidden)
                {
                    result = "IncorrectLoginOrPassword";
                }
                if (request.StatusCode == System.Net.HttpStatusCode.MethodNotAllowed)
                {
                    result = "MethodNotAllowed";
                }
                if (request.StatusCode == System.Net.HttpStatusCode.NoContent || request.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    result = String.Empty;
                }
            }
            catch (AggregateException e)
            {
                result       = e.InnerExceptions[0].Data["message"].ToString();
                loginSuccess = false;
            }
            catch (Exception e)
            {
                result       = e.Message;
                loginSuccess = false;
            }

            return(await Helper.Complete(new VacationUpdateResponce(vacation.Id, loginSuccess, result)));
        }
Exemplo n.º 13
0
        public async Task TestSQLServiceDeleteVacation()
        {
            await InitData();

            VacationsDataService _vacationsDataService = FactorySingleton.FactoryOffline.Get <VacationsDataService>();
            List <VTSModel>      list = await _vacationsDataService.GetVacationListFromSQL();

            Assert.IsNotNull(list, "Error: vacationsDataService.GetVacationListFromSQL() Is Null");
            Assert.AreEqual(list.Count, (new VacationInfoMockModel().Vacations).Count, "Error: list.Count from SQL != VacationInfoMockModel");
            VTSModel deletedVTS = list[list.Count - 1];
            int      idDeleted  = deletedVTS.Id;
            await _vacationsDataService.DeleteVacationsInSql(deletedVTS);

            list = await _vacationsDataService.GetVacationListFromSQL();

            Assert.IsNotNull(list, "Error: vacationsDataService.GetVacationListFromSQL() Is Null");
            Assert.AreEqual(list.Count, (new VacationInfoMockModel().Vacations).Count - 1, "Error: list.Count from SQL == VacationInfoMockModel after delete");
            foreach (VTSModel vts in list)
            {
                Assert.AreNotEqual(vts.Id, idDeleted, string.Format("Error:  vacationsDataService.DeleteVacationsInSql ID = {0} deleted item is exist after delete", vts.Id));
            }
        }
Exemplo n.º 14
0
        public TestBase()
        {
            _context = new VTSModel(DbConnectionFactory.CreateTransient());

            InitializeDB();

            //Dependency injection configuration
            var builder = new ContainerBuilder();

            builder.Register <IVehicleRepository>(c => new VehicleRepository(_context)).InstancePerLifetimeScope();

            builder.Register <ICustomerRepository>(c => new CustomerRepository(_context)).InstancePerLifetimeScope();

            builder = ServiceRegistry.RegisterForTest(builder);

            var container = builder.Build();

            using (var scope = container.BeginLifetimeScope())
            {
                vehiclesManager = scope.Resolve <IVehiclesManager>();
                customerManager = scope.Resolve <ICustomerManager>();
            }
        }
Exemplo n.º 15
0
 public async Task <bool> DeleteVacationInfo(VTSModel item)
 {
     return(await _vacationManager.DeleteVacation(this, item));
 }