Ejemplo n.º 1
0
        public void InitOwnerData()
        {
            Owner owner1 = new Owner()
            {
                FirstName = "Son",
                LastName  = "Goku",
                Address   = "King kai's 25",
                Email     = "*****@*****.**"
            };

            _ownerRepository.Create(owner1);


            Owner owner3 = new Owner()
            {
                FirstName = "Bart",
                LastName  = "Simpson",
                Address   = "Evergreen Terrace 13",
                Email     = "*****@*****.**"
            };

            _ownerRepository.Create(owner3);

            Owner owner4 = new Owner()
            {
                FirstName = "Clarke",
                LastName  = "Kent",
                Address   = "Metropolis 89",
                Email     = "*****@*****.**"
            };

            _ownerRepository.Create(owner4);
        }
Ejemplo n.º 2
0
        public void InitData()
        {
            var petType = new PetType
            {
                Type = "Golden Retriever"
            };

            var pet1 = new Pet
            {
                Name          = "Rex",
                Type          = "Golden Retriever",
                Color         = "Golden",
                BirthDate     = new DateTime(2018, 6, 10),
                Price         = 100,
                SoldDate      = new DateTime(2018, 7, 10),
                PreviousOwner = "FimFi"
            };

            var owner1 = new Owner
            {
                Name    = "FimFi",
                Address = "Skolegade 13"
            };

            _petTypeRepository.Create(petType);
            _petRepository.Create(pet1);
            _ownerRepository.Create(owner1);
        }
Ejemplo n.º 3
0
        public void InitData()
        {
            var petType = new PetType
            {
                Type = "dyr"
            };

            _petTypeRepository.Create(petType);
            PetTypes.Add(petType);

            var pet1 = new Pet
            {
                Name          = "job",
                Type          = "Dog",
                Color         = "Golden",
                BirthDate     = new DateTime(2018, 6, 10),
                Price         = 100,
                SoldDate      = new DateTime(2018, 7, 10),
                PreviousOwner = "mads"
            };

            var owner1 = new Owner
            {
                Name    = "hans",
                Address = "treet"
            };

            _petRepository.Create(pet1);
            _ownerRepository.Create(owner1);
        }
Ejemplo n.º 4
0
        public void InitData()
        {
            var petType = new PetType
            {
                Type = "hund"
            };

            _petTypeRepository.Create(petType);
            PetTypes.Add(petType);

            var pet1 = new Pet
            {
                Name          = "hundenmads",
                Type          = "hund",
                Color         = "brun",
                BirthDate     = new DateTime(2019, 3, 10),
                Price         = 100,
                SoldDate      = new DateTime(2020, 2, 11),
                PreviousOwner = "mikkel"
            };

            var owner1 = new Owner
            {
                Name    = "frost",
                Address = "vinter"
            };

            _petRepository.Create(pet1);
            _ownerRepository.Create(owner1);
        }
Ejemplo n.º 5
0
        public void InitData()
        {
            var petType = new PetType
            {
                Type = "Giraffe"
            };

            _petTypeRepository.Create(petType);
            PetTypes.Add(petType);

            var pet1 = new Pet
            {
                Name          = "Billy Joel",
                Type          = "Dog",
                Color         = "Golden",
                BirthDate     = new DateTime(2018, 6, 10),
                Price         = 100,
                SoldDate      = new DateTime(2018, 7, 10),
                PreviousOwner = "JohnnyBravo"
            };

            var owner1 = new Owner
            {
                Name    = "MichaelJackson",
                Address = "JohnnyBravo Street"
            };

            _petRepository.Create(pet1);
            _ownerRepository.Create(owner1);
        }
Ejemplo n.º 6
0
 public bool Create(Owner model)
 {
     if (_ownerValidationService.Ownervalidator(model))
     {
         return(_ownerRepository.Create(model));
     }
     return(false);
 }
Ejemplo n.º 7
0
        public AppMutation(IOwnerRepository repository)
        {
            Field <OwnerType>("createOwner",
                              arguments: new QueryArguments(
                                  new QueryArgument <NonNullGraphType <OwnerInputType> > {
                Name = "owner"
            }),
                              resolve: context =>
            {
                var owner = context.GetArgument <Owner>("owner");

                return(repository.Create(owner));
            });


            //update

            Field <OwnerType>(
                "updateOwner",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <OwnerInputType> > {
                Name = "owner"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "Id"
            }),
                resolve: context =>
            {
                var owner   = context.GetArgument <Owner>("owner");
                var ownerId = context.GetArgument <Guid>("Id");
                owner.Id    = ownerId;
                return(repository.Update(owner));
            }
                );

            Field <StringGraphType>(
                "deleteOwner",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "ownerId"
            }),
                resolve: context =>
            {
                var ownerId = context.GetArgument <Guid>("ownerId");
                // if (ownerId == null)
                //{
                //  context.Errors.Add(new ExecutionError("Owner nao encontrado."));
                // return null;
                // }

                repository.Delete(ownerId);
                return($"Owner id: {ownerId} deletado com sucesso.");
            }
                );
        }
Ejemplo n.º 8
0
 public Owner CreateOwner(Owner owner)
 {
     if (owner.Pet == null || owner.Pet.Id <= 0)
     {
         throw new InvalidDataException("To create owner you need a pet");
     }
     if (_petRepo.ReadById(owner.Pet.Id) == null)
     {
         throw new InvalidDataException("Pet not found");
     }
     return(_ownerRepo.Create(owner));
 }
Ejemplo n.º 9
0
        public Owner Create(Owner owner)
        {
            if (owner.Id <= 0)
            {
                throw new NotFiniteNumberException("Id cannot be in negative");
            }

            if (String.IsNullOrEmpty(owner.FirstName) && String.IsNullOrEmpty(owner.LastName))
            {
                throw new InvalidDataException();
            }
            return(_ownerRepository.Create(owner));
        }
Ejemplo n.º 10
0
        public void InitData(PetshopContext context)
        {
            string password = "******";

            byte[] passwordHashJoe, passwordSaltJoe, passwordHashAnn, passwordSaltAnn;
            authenticationHelper.CreatePasswordHash(password, out passwordHashJoe, out passwordSaltJoe);
            authenticationHelper.CreatePasswordHash(password, out passwordHashAnn, out passwordSaltAnn);
            List <User> users = new List <User>
            {
                new User {
                    Username     = "******",
                    PasswordHash = passwordHashJoe,
                    PasswordSalt = passwordSaltJoe,
                    IsAdmin      = false
                },
                new User {
                    Username     = "******",
                    PasswordHash = passwordHashAnn,
                    PasswordSalt = passwordSaltAnn,
                    IsAdmin      = true
                }
            };
            var petType = new PetType
            {
                Type = "Golden Retriever"
            };

            var pet1 = new Pet
            {
                Name          = "Rex",
                Type          = "Golden Retriever",
                Color         = "Golden",
                BirthDate     = new DateTime(2018, 6, 10),
                Price         = 100,
                SoldDate      = new DateTime(2018, 7, 10),
                PreviousOwner = "owner1"
            };

            var owner1 = new Owner
            {
                Name    = "FimFi",
                Address = "Skolegade 13"
            };

            _petTypeRepository.Create(petType);
            _petRepository.Create(pet1);
            _ownerRepository.Create(owner1);
            context.Users.AddRange(users);
            context.SaveChanges();
        }
Ejemplo n.º 11
0
        public ICommandResult Handle(OwnerCreateCommand command)
        {
            if (!command.Validate())
            {
                var notifications = command.Notifications;
                return(new CommandResult(false, "OwnerCreateHandle"
                                         , "Não foi possivel criar o usuário"
                                         , notifications));
            }

            var owner = new Owner(command.Name, command.Address, command.Fone, command.Document);

            _repository.Create(owner);
            return(new CommandResult(true, "OwnerCreateHandle", "Usuário criado com sucesso", null));
        }
Ejemplo n.º 12
0
 public Owner Create(Owner owner)
 {
     if (owner.Id != default)
     {
         throw new NotSupportedException($"The pet id should not be specified");
     }
     else if (string.IsNullOrEmpty(owner.FirstName))
     {
         throw new InvalidDataException("You need to specify the owner's first name.");
     }
     else if (string.IsNullOrEmpty(owner.LastName))
     {
         throw new InvalidDataException("You need to specify the owner's last name.");
     }
     return(_ownerRepository.Create(owner));
 }
Ejemplo n.º 13
0
        public Owner CreateOwner(string firstName, string lastName, string address, string phoneNumber, string email)
        {
            var newOwner = new Owner()
            {
                FirstName   = firstName,
                LastName    = lastName,
                Address     = address,
                Email       = email,
                PhoneNumber = phoneNumber
            };

            if (string.IsNullOrEmpty(newOwner.FirstName))
            {
                throw new InvalidDataException("Owner has to have a firstname");
            }
            _ownerRepository.Create(newOwner);
            return(newOwner);
        }
Ejemplo n.º 14
0
        public void InitData()
        {
            var petType1 = new PetType()
            {
                Name = "Greyhound"
            };

            _petTypeRepo.Create(petType1);

            var pet1 = new Pet()
            {
                Name          = "Bob",
                Type          = "Dog",
                Birthdate     = new DateTime(2019, 05, 05),
                SoldDate      = new DateTime(2020, 05, 05),
                Color         = "Brown",
                PreviousOwner = "Some guy",
                Price         = 5000.00
            };

            _petRepo.Create(pet1);

            var pet2 = new Pet()
            {
                Name          = "Billy",
                Type          = "Cat",
                Birthdate     = new DateTime(2018, 05, 04),
                SoldDate      = new DateTime(2019, 04, 04),
                Color         = "Black",
                PreviousOwner = "Some other guy",
                Price         = 50.00
            };

            _petRepo.Create(pet2);

            var owner1 = new Owner()
            {
                Name    = "Michael",
                Address = "Billy Jean"
            };

            _ownerRepo.Create(owner1);
        }
        public Owner CreateOwner(Owner owner)
        {
            if (owner == null)
            {
                throw new NullReferenceException("Cannot create null owner");
            }

            if (String.IsNullOrEmpty(owner.FirstName))
            {
                throw new InvalidDataException("Owner needs a FirstName to be created");
            }

            if (String.IsNullOrEmpty(owner.LastName))
            {
                throw new InvalidDataException("Owner needs a LastName to be created");
            }

            return(ownerRepos.Create(owner));
        }
Ejemplo n.º 16
0
        public async Task <Response> Create(Owner item)
        {
            Response response = new Response();

            try
            {
                response = await _OwnerRepo.Create(item);

                return(response);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                log.Error(sb.AppendLine(e.Message).AppendLine(e.StackTrace).ToString());
                response.ErrorList.Add("Error on create Owner");
                response.Success = false;
                return(response);
            }
        }
Ejemplo n.º 17
0
        public void InitData()
        {
            /*var address = new Address()
            {
                StreetName = "smurf"
            };
           address = _addressRepo.AddAddress(address);
*/

            var petType1 = new PetType
            {
                Type = "Doggos"
            };
            PetTypes.Add(petType1);

            var pet1 = new Pet
            {
                Name = "John",
                Type = "Dog", 
                BirthDate = new DateTime(2020, 10, 10),
                SoldDate = new DateTime(2020, 10, 10),
                Color = "green",
                PreviousOwner = "gert",
                Price = 434
            };
            Pets.Add(pet1);

            var owner1 = new Owner
            {
                Name = "tiltert",
                Address = "eart"
            };

            _ownerRepo.Create(owner1);
            _petTypeRepo.Create(petType1);
            _petRepo.Create(pet1);
        }
Ejemplo n.º 18
0
 public ActionResult Create(Owner model)
 {
     _ownerRepository.Create(model);
     _ownerRepository.Save();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 19
0
        public void InitData()
        {
            // Only init data if repository is empty
            if (_petRepository.ReadAll().List.Any())
            {
                return;
            }

            _petRepository.Create(new Pet()
            {
                Name          = "Garfield",
                Type          = PetType.Cat,
                BirthDate     = DateTime.Parse("12 Juni 2008", new CultureInfo("da-DK")),
                SoldDate      = DateTime.Parse("12 Juni 2008", new CultureInfo("da-DK")),
                Color         = "Orange",
                PreviousOwner = "Jon Arbuckle",
                Price         = 10
            });

            _petRepository.Create(new Pet()
            {
                Name          = "Snoopy",
                Type          = PetType.Dog,
                BirthDate     = DateTime.Now,
                SoldDate      = DateTime.Parse("12 Juni 2008", new CultureInfo("da-DK")),
                Color         = "White",
                PreviousOwner = "Bob",
                Price         = 50
            });

            _petRepository.Create(new Pet()
            {
                Name          = "Bugs Bunny",
                Type          = PetType.Rabbit,
                BirthDate     = DateTime.Parse("12 Juni 2008", new CultureInfo("da-DK")),
                SoldDate      = DateTime.Parse("12 Juni 2008", new CultureInfo("da-DK")),
                Color         = "Grey/White",
                PreviousOwner = "None",
                Price         = 100
            });

            _ownerRepository.Create(new Owner()
            {
                FirstName = "Blondie",
                LastName  = "The Good",
                Address   = "Sad Hill Cemetery The Unmarked Grave",
                Phone     = "555-GoldAndGuns",
                Email     = "*****@*****.**"
            });

            _userRepository.Create(new User()
            {
                Username = "******",
                Password = "******",
                IsAdmin  = false
            });

            _userRepository.Create(new User()
            {
                Username = "******",
                Password = "******",
                IsAdmin  = true
            });
        }
Ejemplo n.º 20
0
 public Owner Create(Owner owner)
 {
     return(_ownerRepository.Create(owner));
 }
Ejemplo n.º 21
0
 public Owner Add(Owner owner)
 {
     return(_ownerRepo.Create(owner));
 }
Ejemplo n.º 22
0
 public Owner Create(Owner owner)
 {
     ValidateOwnerData(owner);
     return(_ownerRepository.Create(owner));
 }
Ejemplo n.º 23
0
 public Owner CreateOwner(Owner owner)
 {
     return(_ownerRepo.Create(owner));
 }
Ejemplo n.º 24
0
 public Owner CreatOwner(Owner o)
 {
     return(_ownerRepo.Create(o));
 }
Ejemplo n.º 25
0
        public string InitData()
        {
            List <PetType> allPetTypes = new List <PetType>
            {
                new PetType {
                    NameOfPetTypes = "Dog"
                },
                new PetType {
                    NameOfPetTypes = "Cat"
                },
                new PetType {
                    NameOfPetTypes = "Snake"
                },
                new PetType {
                    NameOfPetTypes = "Hawk"
                },
                new PetType {
                    NameOfPetTypes = "Lion"
                },
                new PetType {
                    NameOfPetTypes = "Goat"
                },
                new PetType {
                    NameOfPetTypes = "Lizard"
                },
                new PetType {
                    NameOfPetTypes = "Rabbit"
                },
                new PetType {
                    NameOfPetTypes = "Dragon"
                },
                new PetType {
                    NameOfPetTypes = "Turtle"
                }
            };
            List <Owner> allOwners = new List <Owner>
            {
                new Owner {
                    FirstName   = "Jack", LastName = "Davidson", Address = "Deadwell 3, 6600 Vejen",
                    PhoneNumber = "3333 44444", Email = "*****@*****.**"
                },
                new Owner {
                    FirstName   = "Peter", LastName = "Parker", Address = "Pride 69, 6969 Someplace",
                    PhoneNumber = "6969 6969", Email = "*****@*****.**"
                },
                new Owner {
                    FirstName   = "Clark", LastName = "Kent", Address = "Shittington 3, Smallville",
                    PhoneNumber = "DC Comics 45", Email = "*****@*****.**"
                },
                new Owner {
                    FirstName   = "Tony", LastName = "Stark", Address = "ExpensivePlace 4, Malibu State",
                    PhoneNumber = "I AM IRONMAN 10", Email = "*****@*****.**"
                },
                new Owner {
                    FirstName   = "Steve", LastName = "Rogers", Address = "Brooklyn 4, 1918",
                    PhoneNumber = "America 5504", Email = "*****@*****.**"
                },
                new Owner {
                    FirstName   = "Natasha", LastName = "Romanoff", Address = "Red Room, Russia",
                    PhoneNumber = "0000 0000", Email = "*****@*****.**"
                },
                new Owner {
                    FirstName   = "Bruce", LastName = "Wayne", Address = "Wayne Manor, Gotham City",
                    PhoneNumber = "1234 5678", Email = "*****@*****.**"
                },
                new Owner {
                    FirstName   = "Arthur", LastName = "Curry", Address = "Coral Reef, Atlantis",
                    PhoneNumber = "9012 3456", Email = "*****@*****.**"
                }
            };

            List <Pet> allPets = new List <Pet>
            {
                new Pet {
                    Name          = "Dante", Birthdate = new DateTime(2013, 7, 8), SoldDate = new DateTime(2014, 7, 8),
                    previousOwner = "Uriel Sorensson", Price = 250, PetType = allPetTypes[0], PetOwner = allOwners[0]
                },
                new Pet {
                    Name          = "Vergil", Birthdate = new DateTime(2015, 2, 4), SoldDate = new DateTime(2016, 2, 4),
                    previousOwner = "Bruce Wayne", Price = 750, PetType = allPetTypes[1], PetOwner = allOwners[1]
                },
                new Pet {
                    Name          = "Lady", Birthdate = new DateTime(2014, 5, 2), SoldDate = new DateTime(2016, 2, 4),
                    previousOwner = "Loki Odinson", Price = 360, PetType = allPetTypes[2], PetOwner = allOwners[2]
                },
                new Pet {
                    Name          = "Trish", Birthdate = new DateTime(2012, 6, 4), SoldDate = new DateTime(2012, 7, 3),
                    previousOwner = "Urizen Sparkles", Price = 70, PetType = allPetTypes[3], PetOwner = allOwners[3]
                },
                new Pet {
                    Name          = "Irish", Birthdate = new DateTime(2011, 4, 6), SoldDate = new DateTime(2013, 3, 1),
                    previousOwner = "Simba", Price = 120, PetType = allPetTypes[4], PetOwner = allOwners[4]
                },
                new Pet {
                    Name          = "Barry", Birthdate = new DateTime(1920, 4, 6), SoldDate = new DateTime(2018, 3, 1),
                    previousOwner = "Henry Allen", Price = 30, PetType = allPetTypes[5], PetOwner = allOwners[5]
                },
                new Pet {
                    Name          = "OLiver", Birthdate = new DateTime(1970, 5, 9), SoldDate = new DateTime(2019, 2, 3),
                    previousOwner = "Moira", Price = 306, PetType = allPetTypes[6], PetOwner = allOwners[6]
                },
            };

            foreach (var pet in allPets)
            {
                _petRepo.Create(pet);
            }
            foreach (var owner in allOwners)
            {
                _ownerRepo.Create(owner);
            }
            foreach (var petType in allPetTypes)
            {
                _petTypeRepo.AddNewPetType(petType);
            }
            return("Data has been made.");
        }
Ejemplo n.º 26
0
        public void InitData()
        {
            #region Owners
            var owner1 = new Owner()
            {
                //Id = FakeDB.ownerId++,
                FirstName   = "Arnold",
                SecondName  = "Gus",
                Age         = 45,
                Address     = "Gronningen 24",
                PhoneNumber = 61564432
            };
            _ownerRepository.Create(owner1);

            var owner2 = new Owner()
            {
                FirstName   = "Slim",
                SecondName  = "Shaddy",
                Age         = 22,
                Address     = "Salute 2",
                PhoneNumber = 56477124
            };
            _ownerRepository.Create(owner2);


            var owner3 = new Owner()
            {
                FirstName   = "Bob",
                SecondName  = "McCalckin",
                Age         = 31,
                Address     = "Rabstroy 7",
                PhoneNumber = 56477124
            };
            _ownerRepository.Create(owner3);

            var owner4 = new Owner()
            {
                FirstName   = "Nicklas",
                SecondName  = "Brideman",
                Age         = 31,
                Address     = "Semenyak 28",
                PhoneNumber = 56237124
            };
            _ownerRepository.Create(owner4);
            #endregion
            #region Pet Types
            TypePet type1 = new TypePet()
            {
                Type = "Cat",
            };
            _typePetRepository.Create(type1);


            TypePet type2 = new TypePet()
            {
                Type = "Dog"
            };
            _typePetRepository.Create(type2);

            TypePet type3 = new TypePet()
            {
                Type = "Mouse"
            };
            _typePetRepository.Create(type3);
            #endregion
            #region Pets
            var pet1 = new Pet()
            {
                Name         = "Pees",
                Color        = "Yellow",
                BirthdayDate = new DateTime(2020, 06, 15),
                Price        = 120.00,
                TypePetId    = 2,
                OwnerId      = 1
            };
            _petRepository.Create(pet1);

            var pet2 = new Pet()
            {
                Name         = "Lolkins",
                Color        = "Red",
                BirthdayDate = new DateTime(2020, 02, 01),
                Price        = 133.00,
                TypePetId    = 1,
                OwnerId      = 1
            };
            _petRepository.Create(pet2);
            #endregion
            #region Users
            string password = "******";
            byte[] passwordHashJohn, passwordSaltJohn, passwordHashAnna, passwordSaltAnna;
            _authHelper.CreatePasswordHash(password, out passwordHashJohn, out passwordSaltJohn);
            _authHelper.CreatePasswordHash(password, out passwordHashAnna, out passwordSaltAnna);

            var JohnAdmin = new User()
            {
                Username     = "******",
                PasswordHash = passwordHashJohn,
                PasswordSalt = passwordSaltJohn,
                IsAdmin      = true
            };
            _userRepository.Create(JohnAdmin);

            var AnnaNotAdmin = new User()
            {
                Username     = "******",
                PasswordHash = passwordHashAnna,
                PasswordSalt = passwordSaltAnna,
                IsAdmin      = false
            };
            _userRepository.Create(AnnaNotAdmin);
            #endregion
        }