public bool Register(ClientBl client) { try { var dboClient = new Client { FirstName = "nice" }; _context.Client.Add(dboClient); _context.SaveChanges(); var c = new ClientWeb { IdClient = dboClient.Id, Email = client.Email, Password = client.Password, IdRole = client.idRole }; _context.ClientWeb.Add(c); _context.SaveChanges(); return(true); } catch (Exception ex) { string x = ex.Message; return(false); } }
public BookingBl GetBooking(int IdClient, int IdRoom) { ClientBl clientBl = GetClient(IdClient); RoomBl roomBl = GetRoom(IdRoom); HandlingBl handlingBl = new HandlingBl(); BookingBl bookingBl = new BookingBl { client = clientBl, room = roomBl, handling = handlingBl, }; return(bookingBl); }
public ClientBl Login(LoginModel model) { var clientFull = new ClientBl(); ClientWeb clientWeb = _context.ClientWeb.FirstOrDefault(u => u.Email == model.Email && u.Password == model.Password); Client client = _context.Client.FirstOrDefault(u => u.Id == clientWeb.IdClient); clientFull.Id = client.Id; clientFull.FirstName = client.FirstName; clientFull.LastName = client.LastName; clientFull.Surname = client.Surname; clientFull.Passport = client.Passport; clientFull.DatofBirth = (DateTime)client.DatofBirth; clientFull.Adress = client.Adress; clientFull.Telephone = client.Telephone; clientFull.Email = clientWeb.Email; clientFull.Password = clientWeb.Password; clientFull.idRole = (int)clientWeb.IdRole; return(clientFull); }
public int?CreateClient(ClientBl client) { try { Client cl = new Client(); cl.FirstName = client.FirstName; cl.LastName = client.LastName; cl.Surname = client.Surname; cl.Passport = client.Passport; cl.DatofBirth = (DateTime)client.DatofBirth; cl.Adress = client.Adress; cl.Telephone = client.Telephone; _context.Client.Add(cl); _context.SaveChanges(); ClientWeb clientWeb = new ClientWeb { IdClient = cl.Id, Email = client.Email, Password = client.Password, IdRole = client.idRole, }; _context.ClientWeb.Add(clientWeb); _context.SaveChanges(); return(cl.Id); } catch (Exception ex) { var x = ex.Message; return(null); throw; } }
public ClientBl GetClient(int id) { Client client = _context.Client.FirstOrDefault(p => p.Id == id); ClientWeb clientWeb = _context.ClientWeb.FirstOrDefault(p => p.IdClient == id); ClientBl clientBl = new ClientBl { Id = client.Id, FirstName = client.FirstName, LastName = client.LastName, Surname = client.Surname, Passport = client.Passport, DatofBirth = client.DatofBirth == null ? DateTime.Now : (DateTime)client.DatofBirth, Adress = client.Adress, Telephone = client.Telephone, Email = clientWeb.Email, Password = clientWeb.Password, idRole = clientWeb.IdRole == null ? 0 : (int)clientWeb.IdRole, }; return(clientBl); }
public bool EditClient(ClientBl client) { try { Client cl = new Client { Id = client.Id, FirstName = client.FirstName, LastName = client.LastName, Surname = client.Surname, Passport = client.Passport, DatofBirth = (DateTime)client.DatofBirth, Adress = client.Adress, Telephone = client.Telephone, }; _context.Client.Update(cl); _context.SaveChanges(); ClientWeb clientWeb = new ClientWeb { IdClient = client.Id, Email = client.Email, Password = client.Password, IdRole = client.idRole, }; _context.ClientWeb.Update(clientWeb); _context.SaveChanges(); return(true); } catch (Exception) { return(false); throw; } }
public IHttpActionResult Get() { var clientBl = new ClientBl(); return(Ok(clientBl.GetAll())); }