Example #1
0
        public async Task <IActionResult> Create([Bind("DNI,Nombre,Apellidos,Puntos")] ConductorViewModel conductor)
        {
            object Error;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Add(conductor.ToEntity());
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (Exception ex)
                {
                    var sqlException = ex.InnerException as SqlException;
                    if (sqlException.Number == 2601 || sqlException.Number == 2627)
                    {
                        Error = new ErrorViewModel {
                            Error   = "Error al momento de ingresar la informacion al Sistema.",
                            Message = "Ya se encuentra un conductor registrado con la DNI " + conductor.DNI
                        };
                        return(View("~/Views/Shared/Error.cshtml", Error));
                    }
                }
            }
            Error = new ErrorViewModel
            {
                Error   = "Error al momento de ingresar la información al Sistema.",
                Message = "Verificar la información ingresada"
            };

            return(View("~/Views/Shared/Error.cshtml", Error));
        }
Example #2
0
        // We want to dynamically generate the buttons and their text based on the number of "IDs" gathered in the View Model
        // Unfortunately, XAML doesn't support looping statements of any kind, so I had to move the parent XAML code into this code-behind class
        // This feels messy, but I'm sure there's a better way by creating a custom control?
        private Grid CreateGridOfButtons(ConductorViewModel vmContext)
        {
            var tileGrid = new Grid
            {
                Padding           = ButtonGridPadding,
                VerticalOptions   = ButtonGridVertOptions,
                HorizontalOptions = ButtonGridHorzOptions,
                RowSpacing        = ButtonGridRowSpacing,
                ColumnSpacing     = ButtonGridColumnSpacing,
                RowDefinitions    = CreateRowDefinitions(vmContext),
                ColumnDefinitions = CreateColumnDefinitions(vmContext)
            };

            for (var i = 0; i < vmContext.GetIDsCount(); i++)
            {
                tileGrid.Children.Add(new ThemedNavigationButton
                {
                    Text            = vmContext.GetParentIDText(i),
                    Command         = vmContext.NavigateToViewModel(i),
                    BackgroundColor = ThemedNavigationButton.ButtonBackgroundColor,
                    TextColor       = ThemedNavigationButton.ButtonTextColor,
                    FontSize        = ThemedNavigationButton.ButtonFontSize,
                    FontAttributes  = ThemedNavigationButton.ButtonFontAttributes
                }, 0, i);
            }

            return(tileGrid);
        }
Example #3
0
        private ColumnDefinitionCollection CreateColumnDefinitions(ConductorViewModel vmContext)
        {
            var columnDefinitionCollection = new ColumnDefinitionCollection();

            columnDefinitionCollection.Add(new ColumnDefinition {
                Width = ButtonGridColumnDefWidth
            });

            return(columnDefinitionCollection);
        }
Example #4
0
        private RowDefinitionCollection CreateRowDefinitions(ConductorViewModel vmContext)
        {
            var rowDefinitionCollection = new RowDefinitionCollection();

            for (var i = 0; i < vmContext.GetIDsCount(); i++)
            {
                rowDefinitionCollection.Add(new RowDefinition {
                    Height = ButtonGridRowDefHeight
                });
            }

            return(rowDefinitionCollection);
        }
 public LoginViewModel(ConductorViewModel parent, IEventService eventService)
 {
   this._parent = parent;
   this._eventService = eventService;
 }
 public AddFriendViewModel(ConductorViewModel parent)
 {
   this._parent = parent;
 }
Example #7
0
 public MainViewModel(ConductorViewModel parent)
 {
   this._parent = parent;
 }
 public DisplayErrorViewModel(ConductorViewModel parent)
 {
   this._parent = parent;
 }