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);
     }
 }
Example #2
0
        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;
            }
        }