Пример #1
0
        public void CreatePhoneNumber(long id, ClientPhoneNumberPoco phonenumber)
        {
            ClientPoco c = _db.Clients.Single(cust => cust.Id == id);

            c.PhoneNumbers.Add(phonenumber);
            _db.SaveChanges();
        }
Пример #2
0
        public void DeleteClient(long id)
        {
            ClientPoco c = _db.Clients.Find(id);

            _db.Clients.Remove(c);
            _db.SaveChanges();
        }
Пример #3
0
        public void CreateAddress(long id, ClientAddressPoco address)
        {
            ClientPoco c = _db.Clients.Single(cust => cust.Id == id);

            c.Addresses.Add(address);
            _db.SaveChanges();
        }
Пример #4
0
        /// <summary>
        ///  Return all dtos mapped from the entities.
        /// </summary>
        /// <returns>This returns a list of entities</returns>
        public async Task <IEnumerable <ClientDto> > LoadAsyncAll()
        {
            IEnumerable <ClientDto> dtoCollection = new ObservableCollection <ClientDto>();

            using (var conn = _sqlExecutor.OpenNewDbConnection())
            {
                var cli1 = await conn.GetAsyncAll <CLIENTES1>();

                var cli2 = await conn.GetAsyncAll <CLIENTES2>();

                var poco1       = _mapper.Map <IEnumerable <CLIENTES1>, IEnumerable <ClientPoco> >(cli1);
                var poco2       = _mapper.Map <IEnumerable <CLIENTES2>, IEnumerable <ClientPoco> >(cli2);
                var sortedPoco1 = poco1.OrderBy(x => x.NUMERO_CLI);
                var sortedPoco2 = poco2.OrderBy(x => x.NUMERO_CLI);
                IEnumerator <ClientPoco> iter = sortedPoco2.GetEnumerator();
                var second      = iter.Current;
                var mergedValue = new List <ClientPoco>();
                foreach (var p in sortedPoco1)
                {
                    MergePOCO <ClientPoco>           merger = new MergePOCO <ClientPoco>();
                    IDictionary <string, ClientPoco> ctx    = new Dictionary <string, ClientPoco>();
                    ctx.Add(MergePOCO <ClientPoco> .EntityName, second);
                    ClientPoco poco = merger.Convert(p, ctx);
                    iter.MoveNext();
                    second = iter.Current;
                    mergedValue.Add(poco);
                }
                dtoCollection = _mapper.Map <IEnumerable <ClientPoco>, IEnumerable <ClientDto> >(mergedValue, dtoCollection);
                iter.Dispose();
            }
            return(dtoCollection);
        }
Пример #5
0
        public static ClientPoco GetClients(string ClientID)
        {
            ClientPoco g = null;

            g = GetClients().FirstOrDefault(c => c.ClientUserName == ClientID);
            return(g);
        }
Пример #6
0
        public void DeleteAddress(long clientid, long addressid)
        {
            ClientAddressPoco a = _db.ClientAddresses.Single(ad => ad.AddressId == addressid);
            ClientPoco        c = _db.Clients.Single(cust => cust.Id == clientid);

            c.Addresses.Remove(a);
            _db.SaveChanges();
        }
Пример #7
0
        public void DeletePhoneNumber(long clientid, long phonenumberid)
        {
            ClientPhoneNumberPoco p = _db.ClientPhones.Single(ph => ph.PhoneNumberId == phonenumberid);
            ClientPoco            c = _db.Clients.Single(cust => cust.Id == clientid);

            c.PhoneNumbers.Remove(p);
            _db.SaveChanges();
        }
Пример #8
0
        public void UpdatePhoneNumber(long clientId, long PhoneNumberId, ClientPhoneNumberPoco phonenumber)
        {
            ClientPoco            c = _db.Clients.Single(cu => cu.Id == clientId);
            ClientPhoneNumberPoco p = c.PhoneNumbers.Single(pn => pn.PhoneNumberId == PhoneNumberId);

            p.PhoneNo   = phonenumber.PhoneNo;
            p.PhoneType = phonenumber.PhoneType;
            _db.SaveChanges();
        }
Пример #9
0
        public void UpdateClient(ClientPoco client)
        {
            ClientPoco c = _db.Clients.Single(cu => cu.Id == client.Id);

            c.FirstName = client.FirstName;
            c.LastName  = client.LastName;
            c.DoB       = client.DoB;
            c.SocialIns = client.SocialIns;
            _db.SaveChanges();
        }
Пример #10
0
        public void UpdateAddress(long clientId, long addressId, ClientAddressPoco address)
        {
            ClientPoco        c = _db.Clients.Single(cu => cu.Id == clientId);
            ClientAddressPoco a = c.Addresses.Single(ad => ad.AddressId == addressId);

            a.Street      = address.Street;
            a.Province    = address.Province;
            a.City        = address.City;
            a.Postal_Code = address.Postal_Code;
            _db.SaveChanges();
        }
Пример #11
0
        public static ClientPoco Map(Client client)
        {
            var result = new ClientPoco
            {
                ClientUserName      = client.ClientId,
                Description         = client.Description,
                Secret              = "",
                AccessTokenType     = MapTokenType(client.AccessTokenType),
                AccessTokenLifeTime = client.AccessTokenLifetime,
                ApiScopes           = MapClientScopes(client.AllowedScopes, client.ClientId),
                //  Claims
            };

            return(result);
        }
Пример #12
0
        public static Client Map(ClientPoco poco)
        {
            var result = new Client
            {
                // TODO hard coded configuration
                AlwaysSendClientClaims           = true,
                AlwaysIncludeUserClaimsInIdToken = true,
                AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,

                // TODO Db Configuration
                ClientId            = poco.ClientUserName,
                ClientName          = poco.ClientUserName,
                Description         = poco.Description,
                ClientSecrets       = { new Secret((poco.Secret).Sha256()) },
                AccessTokenType     = MapTokenType(poco.AccessTokenType),
                AccessTokenLifetime = poco.AccessTokenLifeTime,
                AllowedScopes       = MapClientScopes(poco.ApiScopes),
                // TODO need to add userclaims here
                //  Claims
            };

            return(result);
        }
Пример #13
0
 public void Create(ClientPoco client)
 {
     _repository.Create(client);
 }
Пример #14
0
 public void Create(ClientPoco client)
 {
     _db.Clients.Add(client);
     _db.SaveChanges();
 }
Пример #15
0
 public HttpResponseMessage CreateClient([FromBody] ClientPoco client)
 {
     _logic.Create(client);
     _log.Debug("Creating new client.");
     return(Request.CreateResponse(HttpStatusCode.OK));
 }
Пример #16
0
        public HttpResponseMessage UpdateClient([FromBody] ClientPoco client)
        {
            _logic.UpdateClient(client);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Пример #17
0
 public void UpdateClient(ClientPoco client)
 {
     _repository.UpdateClient(client);
 }
Пример #18
0
 public void UpdateClient(ClientPoco client)
 {
     throw new NotImplementedException();
 }
Пример #19
0
 public void Create(ClientPoco client)
 {
     throw new NotImplementedException();
 }