Example #1
0
        bool InterfacePerson.AddPerson(Person person)
        {
            PersonAPI personAPI = new PersonAPI();

            personAPI.AddPerson(person);
            return(true);
        }
 public AccountController()
 {
     string churchCode = GetRequestedChurchCode();
     Model = new ModelFactory<iServeDBProcedures>(new iServeDBDataContext(), GetCurrentUserID());
     OAuthHelper = new OAuthUtil(Config.BaseAPIUrl, churchCode, Config.ApiVersion, Config.F1LoginMethod, Config.ConsumerKey, Config.ConsumerSecret);
     PersonAPI = new PersonAPI(churchCode);
 }
Example #3
0
        public async Task <IActionResult> PutEmployee([FromBody] PersonAPI person)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!(await EmployeeExists(person.Ssn)))
            {
                return(BadRequest());
            }

            try
            {
                Employee employee = EmployeeFactory.Get(person, EmployeeEnum.AssistentLibrarian);
                await _repository.UpdateAsync(employee);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!(await EmployeeExists(person.Ssn)))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #4
0
        bool InterfacePerson.DeletePerson(int id)
        {
            PersonAPI personAPI = new PersonAPI();

            personAPI.DeletePerson(id);
            return(true);
        }
        public async void Update_Member_Phone()
        {
            using (var context = GetContextWithData())
                using (var controller = new MembersController(context))
                {
                    Member mem = context.Members.First();
                    context.Entry(mem).State = EntityState.Detached;

                    PersonAPI person = new PersonAPI()
                    {
                        Address   = "Address 10",
                        Email     = "*****@*****.**",
                        Name      = "Teacher 1",
                        Password  = "******",
                        Phone     = "1010101010",
                        PictureId = "tch1",
                        Ssn       = mem.Ssn
                    };

                    await controller.PutMember(person);

                    var actual = context.Members.AsNoTracking().Where(e => e.Ssn == person.Ssn).FirstOrDefault();

                    Assert.Equal(person.Phone, actual.Phone);
                }
        }
        public static Employee Get(PersonAPI person, EmployeeEnum empType)
        {
            switch (empType)
            {
            case EmployeeEnum.AssistentLibrarian:
                var assistantLibrarian = new AssistantLibrarian(person);
                return((assistantLibrarian.IsValid()) ? assistantLibrarian : null);

            case EmployeeEnum.CheckOutStaff:
                var checkOutStaff = new CheckOutStaff(person);
                return((checkOutStaff.IsValid()) ? checkOutStaff : null);

            case EmployeeEnum.ChiefLibrarian:
                var chiefLibrarianemp = new ChiefLibrarian(person);
                return((chiefLibrarianemp.IsValid()) ? chiefLibrarianemp : null);

            case EmployeeEnum.DepartmentLibrarian:
                var departmentLibrarian = new DepartmentLibrarian(person);
                return((departmentLibrarian.IsValid()) ? departmentLibrarian : null);

            case EmployeeEnum.ReferenceLibrarian:
                var referenceLibrarian = new ReferenceLibrarian(person);
                return((referenceLibrarian.IsValid()) ? referenceLibrarian : null);
            }
            return(null);
        }
Example #7
0
        public async Task <IActionResult> PutMember([FromBody] PersonAPI person)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                Member member = MemberFactory.Get(person, MemberEnum.Student);
                await _repository.UpdateAsync(member);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!(await MemberExists(person.Ssn)))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public Employee(PersonAPI person)
 {
     this.Address   = person.Address;
     this.Email     = person.Email;
     this.Name      = person.Name;
     this.Password  = person.Password;
     this.Phone     = person.Phone;
     this.PictureId = person.PictureId;
     this.Ssn       = person.Ssn;
 }
Example #10
0
        private HomeViewModel()
        {
            lstMenu          = MenuModel.GetMenu();
            CurrentPersonAPI = new PersonAPI();
            LoadContacts();


            EnterMenuOptionCommand           = new Command <int>(EnterMenuOption);
            EnterEditPersonAPIStorageCommand = new Command <string>(EnterEditPersonAPIStorage);
            DeletePersonAPIStorageCommand    = new Command <string>(DeletePersonAPIStorage);
            ViewContactsCommand   = new Command <string>(ViewContacts);
            PlacePhoneCallCommand = new Command <string>(PlacePhoneCall);
        }
Example #11
0
        public void Factory_Create_Employee(string expected, EmployeeEnum empType)
        {
            //Arrange
            PersonAPI person = new PersonAPI()
            {
                Address = "Toldstrupsgade 20", Email = "*****@*****.**", Name = "Michael Schumacher", Password = "******", Phone = "4569637412", PictureId = "testpictureid1", Ssn = 999555111
            };

            //Act
            Employee emp = EmployeeFactory.Get(person, empType);

            //Assert
            Assert.Equal(expected, emp.Title);
        }
Example #12
0
        public void Valid_Email(bool expected, string email)
        {
            //Arrange
            PersonAPI person = new PersonAPI()
            {
                Address = "Toldstrupsgade 20", Email = email, Name = "Michael Schumacher", Password = "******", Phone = "4569637412", PictureId = "testpictureid1", Ssn = 123456789
            };

            //Act
            Employee emp = EmployeeFactory.Get(person, EmployeeEnum.DepartmentLibrarian);

            //Assert
            Assert.Equal(expected, (emp == null));
        }
Example #13
0
        public async void Add_Employee_Existing()
        {
            PersonAPI person = new PersonAPI()
            {
                Address = "Toldstrupsgade 20", Email = "*****@*****.**", Name = "Michael Schumacher", Password = "******", Phone = "1122336652", PictureId = "testpictureid1", Ssn = 999555111
            };

            using (var context = GetContextWithData())
                using (var controller = new EmployeesController(context))
                {
                    var result = await controller.PostEmployee(person, (int)EmployeeEnum.AssistentLibrarian);

                    Assert.IsType <BadRequestResult>(result);
                }
        }
Example #14
0
        public async void Add_Employee(string expected, EmployeeEnum empType)
        {
            PersonAPI person = new PersonAPI()
            {
                Address = "Toldstrupsgade 20", Email = "*****@*****.**", Name = "Michael Schumacher", Password = "******", Phone = "1122336652", PictureId = "testpictureid1", Ssn = 999557811
            };

            using (var context = GetContextWithData())
                using (var controller = new EmployeesController(context))
                {
                    var result = await controller.PostEmployee(person, (int)empType);

                    var emp = context.Employees.FirstOrDefault(e => e.Ssn == person.Ssn);
                    Assert.Equal(expected, emp.Title);
                }
        }
 /*creo que para el singleton se pone el contructor privado*/
 private PersonAPIViewModel()
 {
     EnterSearchNewPersonCommand = new Command(EnterSearchNewPerson);
     AddNewPersonAPICommand      = new Command(AddNewPersonAPI);
     EnterAddPersonAPICommand    = new Command(EnterAddPersonAPI);
     DeletePersonAPICommand      = new Command(DeletePerson);
     AddNewPhotoPersonAPICommand = new Command(AddNewPhotoPersonAPI);
     CurrentPersonAPI            = new PersonAPI();
     State = false;
     lstTiposClientes.Add(Model.CustomerTypes.Contado.ToString());
     lstTiposClientes.Add(Model.CustomerTypes.Crédito.ToString());
     lstPersonAPI.Clear();
     lstPersonAPIPerson.Clear();
     DateOfAdmission = DateTimeOffset.Now;
     message         = new MessageModel();
 }
Example #16
0
        public async void Update_Employee_Wrong_SSN()
        {
            using (var context = GetContextWithData())
                using (var controller = new EmployeesController(context))
                {
                    var       ssn    = 852123951;
                    PersonAPI person = new PersonAPI()
                    {
                        Address = "Toldstrupsgade 450", Email = "*****@*****.**", Name = "Michaelionm Schumacher", Password = "******", Phone = "1122336652", PictureId = "testpictureid1", Ssn = ssn
                    };

                    var result = await controller.PutEmployee(person);

                    Assert.IsType <BadRequestResult>(result);
                }
        }
        public void Factory_Create_Member(int expected, MemberEnum memType)
        {
            PersonAPI person = new PersonAPI()
            {
                Address   = "Address 2",
                Email     = "*****@*****.**",
                Name      = "Student 2",
                Password  = "******",
                Phone     = "2222222222",
                PictureId = "std2",
                Ssn       = 223344556
            };

            Member mem = MemberFactory.Get(person, memType);

            Assert.Equal(expected, mem.LoanRuleId);
        }
Example #18
0
        public void Add_Employee_With_Invalid_Email(string email)
        {
            PersonAPI person = new PersonAPI()
            {
                Address = "Toldstrupsgade 20", Email = email, Name = "Michael Schumacher", Password = "******", Phone = "1122336652", PictureId = "testpictureid1", Ssn = 123456788
            };

            using (var context = GetContextWithData())
                using (var controller = new EmployeesController(context))
                {
                    var result = controller.PostEmployee(person, 2);

                    var      emp      = context.Employees.FirstOrDefault(e => e.Ssn == person.Ssn);
                    Employee expected = null;

                    Assert.Equal(expected, emp);
                }
        }
Example #19
0
        public async void Update_Employee_Password()
        {
            using (var context = GetContextWithData())
                using (var controller = new EmployeesController(context))
                {
                    Employee emp = context.Employees.First();
                    context.Entry(emp).State = EntityState.Detached;

                    PersonAPI person = new PersonAPI()
                    {
                        Address = "Toldstrupsgade 450", Email = "*****@*****.**", Name = "Michaelionm Schumacher", Password = "******", Phone = "1122336652", PictureId = "testpictureid1", Ssn = emp.Ssn
                    };

                    await controller.PutEmployee(person);

                    var actual = context.Employees.AsNoTracking().Where(e => e.Ssn == person.Ssn).FirstOrDefault();

                    Assert.Equal(person.Password, actual.Password);
                }
        }
        public async void Add_Student_Existing()
        {
            PersonAPI person = new PersonAPI()
            {
                Address   = "Los Angeles",
                Email     = "*****@*****.**",
                Name      = "John Doe",
                Password  = "******",
                Phone     = "77665544",
                PictureId = "pcId",
                Ssn       = 334455667
            };

            using (var context = GetContextWithData())
                using (var controller = new MembersController(context))
                {
                    var result = await controller.PostMember(person, (int)MemberEnum.Student);

                    Assert.IsType <BadRequestResult>(result);
                }
        }
        public async void Add_Student_Wrong_PHONE()
        {
            PersonAPI person = new PersonAPI()
            {
                Address   = "New York",
                Email     = "*****@*****.**",
                Name      = "John Doe",
                Password  = "******",
                Phone     = "887766",
                PictureId = "pcId",
                Ssn       = 225566778
            };

            using (var context = GetContextWithData())
                using (var controller = new MembersController(context))
                {
                    var result = await controller.PostMember(person, (int)MemberEnum.Student);

                    Assert.IsType <BadRequestResult>(result);
                }
        }
        public void Insert()
        {
            //Inserta contacto
            var       realmDB = Realm.GetInstance();
            PersonAPI elContactoAlmacenado = realmDB.All <PersonAPI>().FirstOrDefault(b => b.Cedula == CurrentPersonAPI.Cedula);
            UserModel elUsuarioActual      = realmDB.All <UserModel>().FirstOrDefault(b => b.Name.Equals(Settings.UserName));

            if (elContactoAlmacenado == null)
            {
                var realmDB2 = Realm.GetInstance();
                realmDB2.Write(() =>
                {
                    CurrentPersonAPI.IdUser          = elUsuarioActual.Id;
                    CurrentPersonAPI.DateOfAdmission = DateOfAdmission;
                    realmDB2.Add(CurrentPersonAPI);
                });
            }
            else
            {
                message.Title   = "Error";
                message.Message = "Este contacto ya existe";
                message.Cancel  = "Aceptar";
                message.MostrarMensaje(message);
            }

            //inserta ubicacion del usuario

            //List<LocationModel> laListaDeContactos = realmDB.All<LocationModel>().ToList();
            LocationModel ubicacion = new LocationModel();

            realmDB.Write(() =>
            {
                ubicacion.latitud     = latitud;
                ubicacion.longitud    = longitud;
                ubicacion.cedula      = CurrentPersonAPI.Cedula;
                ubicacion.descripcion = CurrentPersonAPI.Fullname;
                ubicacion.idUser      = elUsuarioActual.Id;
                realmDB.Add(ubicacion);
            });
        }
Example #23
0
        public async Task <IActionResult> PostMember([FromBody] PersonAPI person, [FromRoute] int memberType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (await MemberExists(person.Ssn))
            {
                return(BadRequest());
            }

            Member member = MemberFactory.Get(person, (MemberEnum)memberType);

            if (member == null)
            {
                return(BadRequest());
            }

            await _repository.AddAsync(member);

            return(CreatedAtAction("GetMember", new { id = member.Ssn }, member));
        }
Example #24
0
        public async Task <IActionResult> PostEmployee([FromBody] PersonAPI person, [FromRoute] int empType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (await EmployeeExists(person.Ssn))
            {
                return(BadRequest());
            }

            Employee employee = EmployeeFactory.Get(person, (EmployeeEnum)empType);

            if (employee == null)
            {
                return(BadRequest());
            }

            await _repository.AddAsync(employee);

            return(CreatedAtAction("GetEmployee", new { id = employee.Ssn }, employee));
        }
        public async void Add_Student()
        {
            PersonAPI person = new PersonAPI()
            {
                Address   = "New York",
                Email     = "*****@*****.**",
                Name      = "John Doe",
                Password  = "******",
                Phone     = "1199887766",
                PictureId = "pcId",
                Ssn       = 112233446
            };

            using (var context = GetContextWithData())
                using (var controller = new MembersController(context))
                {
                    var result = await controller.PostMember(person, (int)MemberEnum.Student);

                    var mems = await controller.GetMembers();

                    var mem = mems.Where(m => m.Ssn == person.Ssn).FirstOrDefault();
                    Assert.True(mem is Student);
                }
        }
        public static Member Get(PersonAPI person, MemberEnum member)
        {
            switch (member)
            {
            case MemberEnum.Student:
                var student = new Student(person);
                if (student.IsValid())
                {
                    return(student);
                }
                return(null);

            case MemberEnum.Teacher:
                var teacher = new Teacher(person);
                if (teacher.IsValid())
                {
                    return(teacher);
                }
                return(null);

            default:
                return(null);
            }
        }
        public async void Add_Member(int expected, MemberEnum memType)
        {
            PersonAPI person = new PersonAPI()
            {
                Address   = "Address 2",
                Email     = "*****@*****.**",
                Name      = "Student 2",
                Password  = "******",
                Phone     = "1234567896",
                PictureId = "std2",
                Ssn       = 123852357
            };

            using (var context = GetContextWithData())
                using (var controller = new MembersController(context))
                {
                    var result = await controller.PostMember(person, (int)memType);

                    var mems = await controller.GetMembers();

                    var mem = mems.Where(m => m.Ssn == person.Ssn).FirstOrDefault();
                    Assert.Equal(expected, mem.LoanRuleId);
                }
        }
Example #28
0

        
Example #29
0
 public DepartmentLibrarian(PersonAPI person) : base(person)
 {
 }
 public AccountController(IModelFactory<iServeDBProcedures> modelFactory, PersonAPI personAPI, OAuthUtil oauthHelper)
 {
     Model = modelFactory;
     PersonAPI = PersonAPI;
     OAuthHelper = oauthHelper;
 }
Example #31
0
 public ReferenceLibrarian(PersonAPI person) : base(person)
 {
 }
Example #32
0
 public Student(PersonAPI person) : base(person)
 {
     this.LoanRuleId = 1; // hard coded --- to be remove from here
 }