public void TestCreateClientRecordAsync() { ContextSeeders.Seed(); var crbo = new ClientRecordBusinessObject(); var lubo = new LennyouseUserBusinessObject(); var pbo = new PersonBusinessObject(); var _lennyouseUser = new LennyouseUser(Guid.NewGuid()); lubo.Create(_lennyouseUser); var _person = new Person(123456789, 934657823, "Miguel", "Silva", DateTime.UtcNow, _lennyouseUser.Id); pbo.Create(_person); var rbo = new RestaurantBusinessObject(); var _resturant = new Restaurant("Dom Pedro", "Rua das Flores 2", "2 p.m", "9 p.m", "Fridays", 2); rbo.Create(_resturant); var _clientRecord = new ClientRecord(DateTime.UtcNow, _person.Id, _resturant.Id); var resCreate = crbo.CreateAsync(_clientRecord).Result; var resGet = crbo.ReadAsync(_clientRecord.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestUpdatePerson() { ContextSeeders.Seed(); var pbo = new PersonBusinessObject(); var resList = pbo.List(); var item = resList.Result.FirstOrDefault(); var lubo = new LennyouseUserBusinessObject(); var _lennyouseUser = new LennyouseUser(Guid.NewGuid()); lubo.Create(_lennyouseUser); var _newPerson = new Person(3654324444, 1111111, "Marco", "Figueirinha", DateTime.UtcNow, _lennyouseUser.Id); item.VatNumber = _newPerson.VatNumber; item.PhoneNumber = _newPerson.PhoneNumber; item.FirstName = _newPerson.FirstName; item.LastName = _newPerson.LastName; item.BirthDate = _newPerson.BirthDate; item.LennyouseUserId = _newPerson.LennyouseUserId; var resUpdate = pbo.Update(item); resList = pbo.List(); Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().VatNumber == _newPerson.VatNumber && resList.Result.First().PhoneNumber == _newPerson.PhoneNumber && resList.Result.First().FirstName == _newPerson.FirstName && resList.Result.First().LastName == _newPerson.LastName && resList.Result.First().BirthDate == _newPerson.BirthDate && resList.Result.First().LennyouseUserId == _newPerson.LennyouseUserId ); }
public void TestCreateStaffRecordAsync() { ContextSeeders.Seed(); var srbo = new StaffRecordBusinessObject(); var pbo = new PersonBusinessObject(); var rbo = new RestaurantBusinessObject(); var lubo = new LennyouseUserBusinessObject(); var _lennyouseUser = new LennyouseUser(Guid.NewGuid()); lubo.Create(_lennyouseUser); var _person = new Person(1234321, 23432456, "Marco", "Figueirnha", DateTime.UtcNow, _lennyouseUser.Id); pbo.Create(_person); var _restaurant = new Restaurant("Tasca do sol", "Bairro Alto 2", "12h", "00h", "Mondays", 3); rbo.Create(_restaurant); var _staffRecord = new StaffRecord(DateTime.UtcNow, DateTime.UtcNow, _person.Id, _restaurant.Id); var resCreate = srbo.CreateAsync(_staffRecord).Result; var resGet = srbo.ReadAsync(_staffRecord.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestCreateBookingAsync() { ContextSeeders.Seed(); var crbo = new ClientRecordBusinessObject(); var bbo = new BookingBusinessObject(); var pbo = new PersonBusinessObject(); var rbo = new RestaurantBusinessObject(); var lhubo = new LennyouseUserBusinessObject(); var _lennyouseUser = new LennyouseUser(Guid.NewGuid()); var newP = new Person(11111, 11111, "ok", "ok", DateTime.UtcNow, _lennyouseUser.Id); var newR = new Restaurant("ok", "ok", "ok", "ok", "ok", 5); var cr = new ClientRecord(DateTime.UtcNow, newP.Id, newR.Id); var booking = new Booking(cr.Id, DateTime.UtcNow); crbo.Create(cr); pbo.Create(newP); rbo.Create(newR); lhubo.Create(_lennyouseUser); var resCreate = bbo.CreateAsync(booking).Result; var resGet = bbo.ReadAsync(booking.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public ActionResult <string> Login() { var mockUser = new LennyouseUser(); mockUser.Email = "*****@*****.**"; mockUser.PasswordHash = "lkjlkj123"; return(GenerateJsonWebToken(mockUser)); }
public void Create(Person person) { var lennyouseUser = new LennyouseUser(); _context.LennyouseUser.Add(lennyouseUser); person.LennyouseUser = lennyouseUser; person.LennyouseUserId = lennyouseUser.Id; _context.Persons.Add(person); _context.SaveChanges(); }
public void TestCreateLennyouseUserAsync() { ContextSeeders.Seed(); var lubo = new LennyouseUserBusinessObject(); var _lennyouseUser = new LennyouseUser(Guid.NewGuid()); var resCreate = lubo.CreateAsync(_lennyouseUser).Result; var resGet = lubo.ReadAsync(_lennyouseUser.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public void TestCreatePersonAsync() { ContextSeeders.Seed(); var pbo = new PersonBusinessObject(); var lubo = new LennyouseUserBusinessObject(); var _lennyouseUser = new LennyouseUser(Guid.NewGuid()); lubo.Create(_lennyouseUser); var _person = new Person(3654324444, 0000000, "Marco", "Figueirnha", DateTime.UtcNow, _lennyouseUser.Id); var resCreate = pbo.CreateAsync(_person).Result; var resGet = pbo.ReadAsync(_person.Id).Result; Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null); }
public OperationResult Create(LennyouseUser item) { try { _dao.Create(item); return(new OperationResult() { Success = true }); } catch (Exception e) { return(new OperationResult() { Success = false, Exception = e }); } }
private string GenerateJsonWebToken(LennyouseUser user) { var jwtKey = _config["Jwt:Key"]; var keyBytes = Encoding.UTF8.GetBytes(jwtKey); var key = new SymmetricSecurityKey(keyBytes); var credentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); var issuer = _config["Jwt:Issuer"]; var audience = _config["Jwt:Audience"]; var claims = new List <Claim>() { new Claim(JwtRegisteredClaimNames.Sub, user.Email) }; var token = new JwtSecurityToken(issuer, audience, claims, expires: DateTime.Now.AddMinutes(120), signingCredentials: credentials); return(new JwtSecurityTokenHandler().WriteToken(token)); }
public void TestUpdateLennyouseUserAsync() { ContextSeeders.Seed(); var lubo = new LennyouseUserBusinessObject(); var resList = lubo.List(); var item = resList.Result.FirstOrDefault(); var _newLennyouseUser = new LennyouseUser(Guid.NewGuid()); item.PersonId = _newLennyouseUser.PersonId; var resUpdate = lubo.UpdateAsync(item).Result; resList = lubo.ListAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().PersonId == _newLennyouseUser.PersonId); }
public async Task <OperationResult> CreateAsync(LennyouseUser item) { try { await _dao.CreateAsync(item); return(new OperationResult() { Success = true }); } catch (Exception e) { return(new OperationResult() { Success = false, Exception = e }); } }
public void TestUpdateStaffRecord() { ContextSeeders.Seed(); var srbo = new StaffRecordBusinessObject(); var resList = srbo.List(); var item = resList.Result.FirstOrDefault(); var pbo = new PersonBusinessObject(); var rbo = new RestaurantBusinessObject(); var lubo = new LennyouseUserBusinessObject(); var _lennyouseUser = new LennyouseUser(Guid.NewGuid()); lubo.Create(_lennyouseUser); var _person = new Person(3654324444, 0000000, "Marco", "Figueirnha", DateTime.UtcNow, _lennyouseUser.Id); pbo.Create(_person); var _restaurant = new Restaurant("Tasca da Lua", "Bairro Alto 2", "12h", "00h", "Mondays", 7); rbo.Create(_restaurant); var _newStaffRecord = new StaffRecord(DateTime.UtcNow, DateTime.UtcNow, _person.Id, _restaurant.Id); item.BeginDate = _newStaffRecord.BeginDate; item.EndDate = _newStaffRecord.EndDate; item.PersonId = _newStaffRecord.PersonId; item.RestaurantId = _newStaffRecord.RestaurantId; var resUpdate = srbo.Update(item); resList = srbo.List(); Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().BeginDate == _newStaffRecord.BeginDate && resList.Result.First().EndDate == _newStaffRecord.EndDate && resList.Result.First().PersonId == _newStaffRecord.PersonId && resList.Result.First().RestaurantId == _newStaffRecord.RestaurantId ); }
public void TestUpdateBookingAsync() { ContextSeeders.Seed(); var bbo = new BookingBusinessObject(); var resList = bbo.List(); var item = resList.Result.FirstOrDefault(); var crbo = new ClientRecordBusinessObject(); var pbo = new PersonBusinessObject(); var rbo = new RestaurantBusinessObject(); var lhubo = new LennyouseUserBusinessObject(); var _lennyouseUser = new LennyouseUser(Guid.NewGuid()); var newP = new Person(11111, 11111, "ok", "ok", DateTime.UtcNow, _lennyouseUser.Id); var newR = new Restaurant("ok", "ok", "ok", "ok", "ok", 5); var cr = new ClientRecord(DateTime.UtcNow, newP.Id, newR.Id); var booking = new Booking(cr.Id, DateTime.UtcNow); crbo.Create(cr); pbo.Create(newP); rbo.Create(newR); lhubo.Create(_lennyouseUser); item.ClientRecordId = booking.ClientRecordId; var resUpdate = bbo.UpdateAsync(item).Result; resList = bbo.ListAsync().Result; Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().ClientRecordId == booking.ClientRecordId && resList.Result.First().Date == booking.Date); }
public void TestUpdateClientRecord() { ContextSeeders.Seed(); var crbo = new ClientRecordBusinessObject(); var resList = crbo.List(); var item = resList.Result.FirstOrDefault(); var lubo = new LennyouseUserBusinessObject(); var pbo = new PersonBusinessObject(); var rbo = new RestaurantBusinessObject(); var _lennyouseUser = new LennyouseUser(Guid.NewGuid()); lubo.Create(_lennyouseUser); var _person = new Person(98764321, 364857484, "Ana", "Pereira", DateTime.UtcNow, _lennyouseUser.Id); pbo.Create(_person); var _resturant = new Restaurant("Dona Ivone", "Rua dos Anjos 2", "2 p.m", "9 p.m", "Sundays", 2); rbo.Create(_resturant); var _newclientRecord = new ClientRecord(DateTime.UtcNow, _person.Id, _resturant.Id); item.RegisterDate = _newclientRecord.RegisterDate; item.PersonId = _newclientRecord.PersonId; item.RestaurantId = _newclientRecord.RestaurantId; var resUpdate = crbo.Update(item); resList = crbo.List(); Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().RegisterDate == _newclientRecord.RegisterDate && resList.Result.First().RestaurantId == _newclientRecord.RestaurantId && resList.Result.First().PersonId == _newclientRecord.PersonId); }
public async Task UpdateAsync(LennyouseUser lennyouseUser) { _context.Entry(lennyouseUser).State = EntityState.Modified; await _context.SaveChangesAsync(); }
public void Update(LennyouseUser lennyouseUser) { _context.Entry(lennyouseUser).State = EntityState.Modified; _context.SaveChanges(); }
public async Task CreateAsync(LennyouseUser lennyouseUser) { await _context.LennyouseUser.AddAsync(lennyouseUser); await _context.SaveChangesAsync(); }
public void Create(LennyouseUser lennyouseUser) { _context.LennyouseUser.Add(lennyouseUser); _context.SaveChanges(); }