Ejemplo n.º 1
0
        public void TestOneToMany()
        {
            PhoneEntity[] mPhones = new PhoneEntity[5];
            PhoneEntity[] tPhones = new PhoneEntity[5];
            for (int index = 0; index < 5; index++)
            {
                mPhones[index] = new PhoneEntity('M', "158-" + index);
                tPhones[index] = new PhoneEntity('T', "020-" + index);
            }
            PhoneDao phoneDao = new PhoneDao();

            phoneDao.save(mPhones);
            phoneDao.save(tPhones);

            CatEntity           cat    = new CatEntity("lisi", 'F', 100.0f);
            IList <PhoneEntity> phones = new List <PhoneEntity>();

            phones.Add(mPhones[0]);
            phones.Add(tPhones[0]);
            cat.Phones = phones;
            CatDao catDao = new CatDao();

            catDao.save(cat);

            CatEntity getCat = catDao.getByName("lisi");
        }
Ejemplo n.º 2
0
        public ContactsEntity convertRequestToEntity(ContactRequestDTO contact)
        {
            List <PhoneEntity> phones = new List <PhoneEntity>();

            foreach (ContactPhoneDTO phoneDTO in contact.phone)
            {
                PhoneEntity phoneEntity = new PhoneEntity
                {
                    type   = phoneDTO.type,
                    number = phoneDTO.number
                };

                phones.Add(phoneEntity);
            }

            ContactsEntity contactEntity = new ContactsEntity
            {
                first  = contact.name.first,
                middle = contact.name.middle,
                last   = contact.name.last,
                state  = contact.address.state,
                street = contact.address.street,
                city   = contact.address.city,
                zip    = contact.address.zip,
                phones = phones,
                email  = contact.email
            };

            return(contactEntity);
        }
Ejemplo n.º 3
0
        public void DeleteClientPhone(int id, PhoneEntity phone)
        {
            if (phone == null)
            {
                throw new ArgumentNullException("phone", "phone is null");
            }

            if (phone.Id <= 0)
            {
                throw new ArgumentNullException("phone.Id", "phone.ID is null");
            }

            if (id <= 0)
            {
                throw new ArgumentNullException("id", "ID is null");
            }

            using (Petz_dbEntities db = new Petz_dbEntities())
            {
                petz_Client_Phone p = db.petz_Client_Phone.FirstOrDefault(x => x.phone_id == phone.Id && x.client_id == id);
                if (p != null)
                {
                    db.petz_Client_Phone.Remove(p);
                    db.SaveChanges();
                }
                else
                {
                    throw new Exception("This phone (" + phone.Id + ") is not this client (" + id + ")");
                }
            }
        }
Ejemplo n.º 4
0
        public void setup()
        {
            //TODO looking to bogus for fake test data generation
            name = new ContactNameDTO
            {
                first  = "Paul",
                middle = "Muad Dib",
                last   = "Atreides"
            };

            address = new ContactAddressDTO
            {
                state  = "Arrakis",
                city   = "Sietch Tabr",
                street = "100 sietch lane",
                zip    = "10000"
            };

            phones = new List <ContactPhoneDTO>();
            ContactPhoneDTO phoneDTO = new ContactPhoneDTO
            {
                type   = "mobile",
                number = "100-100-100"
            };

            phones.Add(phoneDTO);


            contactResponseDTO = new ContactResponseDTO
            {
                Id      = 1,
                name    = name,
                address = address,
                phone   = phones,
                email   = "*****@*****.**"
            };

            phoneEntities = new List <PhoneEntity>();
            PhoneEntity phone = new PhoneEntity
            {
                type   = "mobile",
                number = "100-100-100"
            };

            phoneEntities.Add(phone);
            contactsEntity = new ContactsEntity
            {
                first  = "Paul",
                middle = "Muad Dib",
                last   = "Atreides",
                state  = "Arrakis",
                city   = "Sietch Tabr",
                street = "100 sietch lane",
                zip    = "10000",
                phones = phoneEntities,
                email  = "*****@*****.**"
            };
        }
Ejemplo n.º 5
0
 public void Add(Phone phone)
 {
     using (PhoneStoreContext context = new PhoneStoreContext())
     {
         PhoneEntity phoneEntity = (PhoneEntity) new PhoneEntity().FromApplicationModel(phone);
         context.Phones.Add(phoneEntity);
         context.SaveChanges();
     }
 }
Ejemplo n.º 6
0
        public async Task <IActionResult> DeletePhones([FromBody] PhoneEntityView view)
        {
            PhoneModule invMod = new PhoneModule();
            PhoneEntity phones = await invMod.Phone.Query().MapToEntity(view);

            invMod.Phone.DeletePhones(phones).Apply();

            return(Ok(view));
        }
Ejemplo n.º 7
0
 public bool Delete(PhoneEntity entity)
 {
     try
     {
         _phoneRepository.Delete(entity);
         return(true);
     }
     catch (Exception e)
     {
         _log.Error(e, "数据库操作出错");
         return(false);
     }
 }
Ejemplo n.º 8
0
 public PhoneEntity Update(PhoneEntity entity)
 {
     try
     {
         _phoneRepository.Update(entity);
         return(entity);
     }
     catch (Exception e)
     {
         _log.Error(e, "数据库操作出错");
         return(null);
     }
 }
Ejemplo n.º 9
0
        internal static PhoneDto ToDto(this PhoneEntity ent)
        {
            if (ent == null)
            {
                return(null);
            }

            return(new PhoneDto
            {
                Number = ent.Number,
                PhoneType = (PhoneType)ent.TypeId
            });
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> UpdatePhones([FromBody] PhoneEntityView view)
        {
            PhoneModule invMod = new PhoneModule();

            PhoneEntity phones = await invMod.Phone.Query().MapToEntity(view);


            invMod.Phone.UpdatePhones(phones).Apply();

            PhoneEntityView retView = await invMod.Phone.Query().GetViewById(phones.PhoneId);


            return(Ok(retView));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> AddPhones([FromBody] PhoneEntityView view)
        {
            PhoneModule invMod = new PhoneModule();

            NextNumber nnPhones = await invMod.Phone.Query().GetNextNumber();

            view.PhoneEntityNumber = nnPhones.NextNumberValue;

            PhoneEntity phones = await invMod.Phone.Query().MapToEntity(view);

            invMod.Phone.AddPhones(phones).Apply();

            PhoneEntityView newView = await invMod.Phone.Query().GetViewByNumber(view.PhoneEntityNumber);


            return(Ok(newView));
        }
Ejemplo n.º 12
0
 public HttpResponseMessage AddFollower(FollowerModel followerModel)
 {
     if (followerModel != null)
     {
         var followerentity = new FollowerEntity
         {
             Openid        = followerModel.Openid,
             Nickname      = followerModel.Nickname,
             Sex           = followerModel.Sex,
             City          = followerModel.City,
             Country       = followerModel.Country,
             Private       = followerModel.Private,
             Language      = followerModel.Language,
             Headimgurl    = followerModel.Headimgurl,
             Subscribetime = followerModel.Subscribe_time,
             Unioid        = followerModel.Unioid,
             Remark        = followerModel.Remark,
             Groupid       = followerModel.Groupid,
             Adduser       = followerModel.Adduser,
             Addtime       = DateTime.Now,
             Upuser        = followerModel.Upuser,
             Uptime        = DateTime.Now
         };
         var phoneentity = new PhoneEntity
         {
             Follower = _followerService.Create(followerentity),
             Openid   = followerModel.Openid,
             Phone    = followerModel.Phone,
             Adduser  = followerModel.Adduser,
             Addtime  = DateTime.Now,
             Upuser   = followerModel.Upuser,
             Uptime   = DateTime.Now
         };
         try
         {
             _phoneService.Create(phoneentity);
             return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!")));
         }
         catch
         {
             return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!")));
         }
     }
     return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据验证错误!")));
 }
Ejemplo n.º 13
0
        public ResponseMessage DeleteClientPhone(PhoneEntity phone)
        {
            ResponseMessage replay = new ResponseMessage();

            try
            {
                int id = ValidSecurityToken(authHeader);
                ClientsController controller = new ClientsController();
                controller.DeleteClientPhone(id, phone);
                replay.Success = true;
                replay.Message = "phone delete successfully";
                return(replay);
            }
            catch (Exception ex)
            {
                replay.Success   = false;
                replay.Message   = ex.Message;
                replay.Exception = ex.Treatment();
                return(replay);
            }
        }
Ejemplo n.º 14
0
        public async Task TestAddUpdatDelete()
        {
            PhoneModule PhoneMod    = new PhoneModule();
            AddressBook addressBook = await PhoneMod.AddressBook.Query().GetEntityById(1);

            PhoneEntityView view = new PhoneEntityView()
            {
                PhoneNumber = "208-606-6785",
                PhoneType   = "Mobile",
                AddressId   = addressBook.AddressId,
                Name        = addressBook.Name
            };
            NextNumber nnNextNumber = await PhoneMod.Phone.Query().GetNextNumber();

            view.PhoneEntityNumber = nnNextNumber.NextNumberValue;

            PhoneEntity phones = await PhoneMod.Phone.Query().MapToEntity(view);

            PhoneMod.Phone.AddPhones(phones).Apply();

            PhoneEntity newPhones = await PhoneMod.Phone.Query().GetEntityByNumber(view.PhoneEntityNumber);

            Assert.NotNull(newPhones);

            newPhones.PhoneType = "Mobile U";

            PhoneMod.Phone.UpdatePhones(newPhones).Apply();

            PhoneEntityView updateView = await PhoneMod.Phone.Query().GetViewById(newPhones.PhoneId);

            Assert.Same(updateView.PhoneType, "Mobile U");
            PhoneMod.Phone.DeletePhones(newPhones).Apply();
            PhoneEntity lookupPhones = await PhoneMod.Phone.Query().GetEntityById(view.PhoneId);

            Assert.Null(lookupPhones);
        }
Ejemplo n.º 15
0
        public void setup()
        {
            phoneEntities = new List <PhoneEntity>();
            PhoneEntity phone = new PhoneEntity
            {
                type   = "mobile",
                number = "100-100-100"
            };

            phoneEntities.Add(phone);
            contactsEntity = new ContactsEntity
            {
                Id     = 1,
                first  = "Paul",
                middle = "Muad Dib",
                last   = "Atreides",
                state  = "Arrakis",
                city   = "Sietch Tabr",
                street = "100 sietch lane",
                zip    = "10000",
                phones = phoneEntities,
                email  = "*****@*****.**"
            };
        }
Ejemplo n.º 16
0
 public IFluentPhone AddPhones(PhoneEntity newObject)
 {
     unitOfWork.phoneRepository.AddObject(newObject);
     this.processStatus = CreateProcessStatus.Insert;
     return(this as IFluentPhone);
 }
Ejemplo n.º 17
0
 String GetCollectionItemXmlElementName(PhoneEntity complexProperty)
 {
     return(XmlElementNames.NlgPhone);
 }
Ejemplo n.º 18
0
        public async Task TestAddUpdatDelete()
        {
            CustomerModule CustomerMod = new CustomerModule();
            AddressBook    addressBook = await CustomerMod.AddressBook.Query().GetEntityById(1);

            LocationAddress shipToLocationAddress = await CustomerMod.LocationAddress.Query().GetEntityById(3);

            LocationAddress mailingLocationAddress = await CustomerMod.LocationAddress.Query().GetEntityById(3);

            LocationAddress billingLocationAddress = await CustomerMod.LocationAddress.Query().GetEntityById(3);

            PhoneEntity phone = await CustomerMod.Phone.Query().GetEntityById(1);

            EmailEntity emailEntity = await CustomerMod.Email.Query().GetEntityById(1);

            CustomerView view = new CustomerView()
            {
                AddressId    = addressBook.AddressId,
                CustomerName = addressBook.Name,
                FirstName    = addressBook.FirstName,
                LastName     = addressBook.LastName,

                PrimaryEmailId    = emailEntity?.EmailId,
                AccountEmail      = emailEntity?.Email,
                AccountEmailLogin = emailEntity?.LoginEmail ?? false,

                PrimaryShippedToLocationAddressId = shipToLocationAddress?.LocationAddressId,
                ShipToAddressLine1 = shipToLocationAddress?.AddressLine1,
                ShipToAddressLine2 = shipToLocationAddress?.AddressLine2,
                ShipToCity         = shipToLocationAddress?.City,
                ShipToZipcode      = shipToLocationAddress?.Zipcode,

                MailingLocationAddressId = mailingLocationAddress?.LocationAddressId,
                MailingAddressLine1      = mailingLocationAddress?.AddressLine1,
                MailingAddressLine2      = mailingLocationAddress?.AddressLine2,
                MailingCity    = mailingLocationAddress?.City,
                MailingZipcode = mailingLocationAddress?.Zipcode,

                PrimaryBillingLocationAddressId = billingLocationAddress?.LocationAddressId,
                BillingAddressLine1             = billingLocationAddress?.AddressLine1,
                BillingAddressLine2             = billingLocationAddress?.AddressLine2,
                BillingCity    = billingLocationAddress?.City,
                BillingZipcode = billingLocationAddress?.Zipcode,

                PrimaryPhoneId = phone.PhoneId,
                PhoneNumber    = phone.PhoneNumber,

                TaxIdentification = "tax id"
            };
            NextNumber nnNextNumber = await CustomerMod.Customer.Query().GetNextNumber();

            view.CustomerNumber = nnNextNumber.NextNumberValue;

            Customer customer = await CustomerMod.Customer.Query().MapToEntity(view);

            CustomerMod.Customer.AddCustomer(customer).Apply();

            Customer newCustomer = await CustomerMod.Customer.Query().GetEntityByNumber(view.CustomerNumber);

            Assert.NotNull(newCustomer);

            newCustomer.AddressId = 17;

            CustomerMod.Customer.UpdateCustomer(newCustomer).Apply();

            CustomerView updateView = await CustomerMod.Customer.Query().GetViewById(newCustomer.CustomerId);

            if (updateView.AddressId != 17)
            {
                Assert.True(true);
            }
            CustomerMod.Customer.DeleteCustomer(newCustomer).Apply();
            Customer lookupCustomer = await CustomerMod.Customer.Query().GetEntityById(view.CustomerId);

            Assert.Null(lookupCustomer);
        }
Ejemplo n.º 19
0
 public EventRepository()
 {
     this._phoneentity = new PhoneEntity();
     this._dbset       = _phoneentity.Set <Event>();
 }
Ejemplo n.º 20
0
 public IFluentPhone DeletePhones(PhoneEntity deleteObject)
 {
     unitOfWork.phoneRepository.DeleteObject(deleteObject);
     this.processStatus = CreateProcessStatus.Delete;
     return(this as IFluentPhone);
 }
Ejemplo n.º 21
0
 public PhoneNumberReposirory()
 {
     this._phoneentity = new PhoneEntity();
     this._dbset       = _phoneentity.Set <PhoneNumber>();
 }
Ejemplo n.º 22
0
 public ContactRepository()
 {
     this._phoneentity = new PhoneEntity();
     this._dbset       = _phoneentity.Set <Contact>();
 }