Example #1
0
        public IActionResult InsertOrUpdateTypePerson(TypePerson typePerson)
        {
            if (ModelState.IsValid)
            {
                Action action = Action.None;
                if (typePerson.Id == 0)
                {
                    action = Action.Create;
                    _unitWork.TypePerson.Add(typePerson);
                }
                else
                {
                    action = Action.Update;
                    _unitWork.TypePerson.Update(typePerson);
                }

                try
                {
                    _unitWork.Save();

                    if (action == Action.Create)
                    {
                        _notyfService.Success("Tipo de persona creada correctamente.");
                    }
                    if (action == Action.Update)
                    {
                        _notyfService.Success("Tipo de persona actualizada correctamente.");
                    }

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateException dbUpdateException)
                {
                    if (dbUpdateException.InnerException.Message.Contains("IX_TypePeople_Name"))
                    {
                        _notyfService.Error("Ya existe un tipo de persona con el mismo nombre.");

                        return(View(typePerson));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, dbUpdateException.InnerException.Message);
                    }
                }
                catch (Exception exception)
                {
                    ModelState.AddModelError(string.Empty, exception.Message);
                }
            }

            return(View(typePerson));
        }
Example #2
0
        public IActionResult InsertOrUpdateTypePerson(int?id)
        {
            TypePerson typePerson = new TypePerson();

            if (id == null)
            {
                typePerson.Active = true;
                // Crea un nuevo registro
                return(View(typePerson));
            }
            // Actualiza el registro
            typePerson = _unitWork.TypePerson.Get(id.GetValueOrDefault());
            if (typePerson == null)
            {
                return(NotFound());
            }
            return(View(typePerson));
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Account"/> class
 /// </summary>
 /// <param name="barcode">barcode that identifies</param>
 /// <param name="password">Password</param>
 /// <param name="TypeOfPerson"></param>
 public Account(Barcode barcode, string password, TypePerson TypeOfPerson)
 {
 }
Example #4
0
 public Person(int id, string name, TypePerson type = TypePerson.Speaker)
 {
     Id           = id;
     Name         = name;
     RankingValue = new Random().Next(0, 100);
 }
Example #5
0
 public Profile(string userId, TypePerson genre)
 {
     UserId = userId;
     Genre  = genre;
 }