예제 #1
0
        public void Setup()
        {
            new DataStoreTableHelper().clearAllTables();

            ClientModel clientModel = new ClientModel();

            clientModel.name  = "Bob";
            clientModel.phone = "1234567890";
            clientModel.email = "*****@*****.**";

            ClientTable clientTable = new ClientTable();

            clientId = clientTable.create(clientModel);

            DogModel dogModel = new DogModel();

            dogModel.clientID = clientId;
            dogModel.name     = "Dog";
            dogModel.age      = 6;
            dogModel.breed    = "Terrier";
            dogModel.experienceOrQualification = false;

            DogTable dogTable = new DogTable();

            dogId = dogTable.create(dogModel);

            ProgramTypeModel programTypeModel = new ProgramTypeModel();

            programTypeModel.description = "Regular";

            ProgramTypeTable programTypeTable = new ProgramTypeTable();

            programTypeId = programTypeTable.create(programTypeModel);
        }
예제 #2
0
파일: FightRoom.cs 프로젝트: hlslml77/fist
        /// <summary>
        /// 开启定时任务:30秒之后产生小兵
        /// </summary>
        private void spawnDog()
        {
            this.StartSchedule(DateTime.UtcNow.AddSeconds(30),
                               delegate
            {
                List <DogModel> dogs = new List <DogModel>();

                for (int i = 0; i < 5; i++)
                {
                    //产生小兵
                    DogModel dog  = new DogModel();
                    dog.ModelType = ModelType.DOG;
                    //添加映射
                    team1DogModel.Add(dog.Id, dog);
                    dogs.Add(dog);

                    dog           = new DogModel();
                    dog.ModelType = ModelType.DOG;
                    //添加映射
                    team2DogModel.Add(dog.Id, dog);
                    dogs.Add(dog);
                }

                //给 客户端发送 现在出兵了 发送的参数就是 dogs
                //Brocast(OpCode.FightCode, OpFight.Dog, 0, "产生一波兵", null, LitJson.JsonMapper.ToJson(dogs.ToArray()));

                //自身调用自身,无限递归
                spawnDog();
            });
        }
예제 #3
0
        public List <DamageModel> Damage(int skillId, int level, DogModel from, params DogModel[] to)
        {
            List <DamageModel> list = new List <DamageModel>();
            //攻击者的攻击力
            int attack = from.Attack;

            foreach (var item in to)
            {
                //被攻击者的防御力
                int defense = item.Defense;
                //计算伤害
                int damage = attack - defense;
                //掉血
                item.CurrHp -= damage;
                //保证血限大于0
                if (item.CurrHp <= 0)
                {
                    item.CurrHp = 0;
                }
                //添加到列表
                list.Add(new DamageModel(from.Id, item.Id, damage, item.CurrHp == 0, skillId));
            }

            return(list);
        }
예제 #4
0
        public DogModel Get(int id)
        {
            var dog      = unitOfWork.DogRepository.GetById(id);
            var dogModel = new DogModel
            {
                DateOfBirth    = dog.DateOfBirth,
                DogId          = dog.DogId,
                Breed          = dog.Breed,
                GuideIdAndName = new IdNameModel
                {
                    Id   = dog.Guide != null ? dog.Guide.GuideId : 0,
                    Name = dog.Guide != null ? dog.Guide.FirstName + " " + dog.Guide.LastName : "Pies nie ma jeszcze przewodnika"
                },
                Level          = dog.Level,
                Name           = dog.Name,
                Notes          = dog.Notes,
                PhotoBlobUrl   = dog.PhotoBlobUrl,
                Workmodes      = dog.Workmodes,
                CertificateIds = dog.DogCertificates?.Select(x => x.CertificateId).ToList(),
                EventIds       = dog.DogEvents?.Select(x => x.EventId).ToList(),
                TrainingIds    = dog.DogTrainings?.Select(x => x.TrainingId).ToList()
            };

            return(dogModel);
        }
예제 #5
0
    /// <summary>
    /// 创建小兵
    /// </summary>
    /// <param name="response"></param>
    private void OnDog(OperationResponse response)
    {
        DogModel[] dogs = JsonMapper.ToObject <DogModel[]>(response[0].ToString());
        for (int i = 0; i < dogs.Length; i++)
        {
            DogModel   dog    = dogs[i];
            GameObject go     = PoolManager.Instance.GetObject("Dog");
            DogControl con    = go.GetComponent <DogControl>();
            int        myTeam = this.GetTeam(this.Heros, GameData.Player.id);
            //初始化小兵控制器
            con.Init(dog, dog.Team == myTeam);
            con.SetCamp(team1Builds[1].transform, team2Builds[1].transform);

            if (dog.Team == 1)
            {
                con.transform.position = con.camp1.position;
                con.Move(con.camp2.position);
            }
            else
            {
                con.transform.position = con.camp2.position;
                con.Move(con.camp1.position);
            }
            idControlDict.Add(dog.Id, con);
        }
    }
예제 #6
0
        public object RegisterNewDog(DogModel registerDogModel, object guid)
        {
            try
            {
                using (_connection)
                {
                    _connection.OpenAsync();
                    Command = new MySqlCommand("SELECT id FROM clubs WHERE Club_name=@clubname", _connection);
                    Command.Parameters.AddWithValue("clubname", registerDogModel.ClubName);
                    var clubId = Command.ExecuteScalarAsync();

                    Command = new MySqlCommand("INSERT INTO dogs " +
                                               "(Club_id,Name,Breed,Age,Document_info,Parents_info,Date_last_vaccenation,Master_guid,Photo,About) VALUES " +
                                               $"('{clubId}',@name,@breed,@age,@doc,@parents,@date,'{guid}',@photo,@about)", _connection);
                    Command.Parameters.AddWithValue("name", registerDogModel.Name);
                    Command.Parameters.AddWithValue("breed", registerDogModel.Breed);
                    Command.Parameters.AddWithValue("age", registerDogModel.Age);
                    Command.Parameters.AddWithValue("doc", registerDogModel.DocumentInfo);
                    Command.Parameters.AddWithValue("parents", registerDogModel.ParentsName);
                    Command.Parameters.AddWithValue("date", registerDogModel.DateLastVaccenation);
                    Command.Parameters.AddWithValue("photo", registerDogModel.PhotoUrl);
                    Command.Parameters.AddWithValue("about", registerDogModel.About);
                    Command.ExecuteNonQueryAsync();
                    return("Dog Succesfull Register");
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
예제 #7
0
        public List <DamageModel> Damage(int skillId, int level, DogModel from, params DogModel[] to)
        {
            List <DamageModel> list = new List <DamageModel>();
            //攻击者攻击力
            int attack = from.Attack;

            //循环计算伤害
            foreach (DogModel item in to)
            {
                //被攻击者防御力
                int defense = item.Defense;
                //计算伤害
                int damage = attack - defense;
                //掉血
                item.CurrHp -= damage;
                //保证血大于等于0
                if (item.CurrHp <= 0)
                {
                    item.CurrHp = 0;
                }
                list.Add(new DamageModel(skillId, from.Id, item.Id, damage, item.CurrHp == 0));
            }

            return(list);
        }
예제 #8
0
        protected override async Task OnInitializedAsync()
        {
            var myDog = await Client.GetDefaultDog();

            Model       = new DogModel(myDog);
            GenderValue = (int)myDog.Gender;
        }
예제 #9
0
        /// <summary>
        /// 开启定时任务,30秒刷一波小兵
        /// </summary>
        private void spwanDog()
        {
            this.StartSchedule(DateTime.UtcNow.AddSeconds(30), delegate
            {
                List <DogModel> dogs   = new List <DogModel>();
                DogDataModel dataModel = DogData.GetDogData(1);

                for (int i = 0; i < 1; i++)
                {
                    //产生小兵

                    DogModel dog  = new DogModel(DogId, dataModel.TypeId, 1, dataModel.MaxHp, dataModel.Attack, dataModel.Defense, dataModel.AttackDistance, dataModel.Name);
                    dog.ModelType = ModelType.DOG;
                    team1DogModel.Add(dog.Id, dog);
                    dogs.Add(dog);

                    dog           = new DogModel(DogId, dataModel.TypeId, 2, dataModel.MaxHp, dataModel.Attack, dataModel.Defense, dataModel.AttackDistance, dataModel.Name);
                    dog.ModelType = ModelType.DOG;
                    dog.Team      = 2;

                    team2DogModel.Add(dog.Id, dog);
                    dogs.Add(dog);
                }
                //给客户端发送现在出兵了dogs
                Brocast(OpCode.FightCode, OpFight.Dog, 0, "双方产生小兵", null, JsonMapper.ToJson(dogs.ToArray()));

                //无限递归
                spwanDog();
            });
        }
        /// <summary>
        /// this saves the dog to the list
        /// </summary>
        public void SaveDog()
        {
            DogModel dogModel = new DogModel();

            dogModel.Name   = DogName;
            dogModel.Breed  = Breed;
            dogModel.Color  = Color;
            dogModel.Gender = SelectedGender;
            if (Birthday != null)
            {
                dogModel.Birthday = Birthday.ToString("dd.MM.yyyy");
            }

            if (PermanentCastrated)
            {
                dogModel.CastratedSince     = CastratedSince.ToString("dd.MM.yyyy");
                dogModel.PermanentCastrated = true;
            }
            else
            {
                dogModel.EffectiveUntil     = EffectiveUntil.ToString("dd.MM.yyyy");
                dogModel.PermanentCastrated = false;
            }
            if (DiseasesList.Count > 0)
            {
                dogModel.Diseases = new List <DiseasesModel>(DiseasesList);
            }
            if (CharacteristicsList.Count > 0)
            {
                dogModel.Characteristics = new List <CharacteristicsModel>(CharacteristicsList);
            }
            EventAggregationProvider.DogginatorAggregator.PublishOnUIThread(dogModel);
        }
예제 #11
0
        public List <DogModel> Get()
        {
            var dogs      = unitOfWork.DogRepository.GetAll().ToList();
            var dogModels = new List <DogModel>();

            foreach (var dog in dogs)
            {
                var dogModel = new DogModel
                {
                    DateOfBirth    = dog.DateOfBirth,
                    DogId          = dog.DogId,
                    Breed          = dog.Breed,
                    GuideIdAndName = new IdNameModel
                    {
                        Id   = dog.Guide != null ? dog.Guide.GuideId : 0,
                        Name = dog.Guide != null ? dog.Guide.FirstName + " " + dog.Guide.LastName : "Pies nie ma jeszcze przewodnika"
                    },
                    Level          = dog.Level,
                    Name           = dog.Name,
                    Notes          = dog.Notes,
                    PhotoBlobUrl   = dog.PhotoBlobUrl,
                    Workmodes      = dog.Workmodes,
                    CertificateIds = dog.DogCertificates?.Select(x => x.CertificateId).ToList(),
                    EventIds       = dog.DogEvents?.Select(x => x.EventId).ToList(),
                    TrainingIds    = dog.DogTrainings?.Select(x => x.TrainingId).ToList()
                };
                dogModels.Add(dogModel);
            }
            return(dogModels);
        }
예제 #12
0
        public async Task <ActionResult> /*Task<ActionResult>*/ AddDog(DogModel addedDog, HttpPostedFileBase imageFile)
        {
            if (!LoginHelper.IsAuthenticated())
            {
                return(RedirectToAction("Login", "Account", new { returnUrl = this.Request.Url.AbsoluteUri }));
            }
            if (imageFile != null)
            {
                MultipartFormDataContent form = new MultipartFormDataContent();
                var imageStreamContent        = new StreamContent(imageFile.InputStream);
                var byteArrayImageContent     = new ByteArrayContent(imageStreamContent.ReadAsByteArrayAsync().Result);
                byteArrayImageContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
                var imageFileName = imageFile.FileName + Guid.NewGuid().ToString();
                form.Add(byteArrayImageContent, imageFileName, Path.GetFileName(imageFileName));

                var response = client.PostAsync("Dogs/Upload", form).Result;

                if (response.IsSuccessStatusCode)
                {
                    //get blob urls - is it that simple or it has to be returned?

                    var imageBlobUrl = @"https://kgtstorage.blob.core.windows.net/images/" + imageFileName;

                    //add blob urls to model
                    addedDog.PhotoBlobUrl = imageBlobUrl;
                }
                else
                {
                    ViewBag.Message = response.StatusCode;
                    return(View("Error"));
                }
            }

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue("Bearer", LoginHelper.GetToken());
            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, client.BaseAddress + "dogs/");

            addedDog.DateOfBirth = addedDog.DateOfBirth.ToUniversalTime();
            var dogSerialized = JsonConvert.SerializeObject(addedDog);

            message.Content = new StringContent(dogSerialized, System.Text.Encoding.UTF8, "application/json");

            HttpResponseMessage responseMessage = client.SendAsync(message).Result; // await client.SendAsync(message)

            if (responseMessage.IsSuccessStatusCode)                                //200 OK
            {
                //display info
                message.Dispose();
                return(RedirectToAction("Dog", new { id = Int32.Parse(responseMessage.Content.ReadAsStringAsync().Result) }));
                //return View("Dog", responseMessage.Content);
            }
            else    // msg why not ok
            {
                message.Dispose();
                ViewBag.Message = responseMessage.StatusCode;
                return(View("Error"));
            }
        }
예제 #13
0
        public bool CreateDog(DogModel dogModel)
        {
            Dog newDog = new Dog
            {
                Name            = dogModel.Name,
                AdoptedDate     = dogModel.AdoptedDate,
                Birthdate       = dogModel.Birthdate,
                Gender          = (Gender)dogModel.Gender,
                MicrochipNumber = dogModel.MicrochipNumber,
                RabiesTagNumber = dogModel.RabiesTagNumber,
                Fixed           = dogModel.Fixed,
                Created         = DateTime.UtcNow,
                Modified        = DateTime.UtcNow
            };

            using (ISession session = NHibernateSession.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction()) //  Begin a transaction
                {
                    session.Save(newDog);                                     //  Save the user in session
                    transaction.Commit();                                     //  Commit the changes to the database
                }
            }
            return(true);
        }
예제 #14
0
 public bool UpdateDog(DogModel dogModel)
 {
     using (ISession session = NHibernateSession.OpenSession())
     {
         Dog foundDog = session.Query <Dog>().FirstOrDefault(c => c.DogId == dogModel.DogId.Value);
         if (foundDog == null)
         {
             return(false);
         }
         foundDog.Name            = dogModel.Name;
         foundDog.AdoptedDate     = dogModel.AdoptedDate;
         foundDog.Birthdate       = dogModel.Birthdate;
         foundDog.Gender          = (Models.Gender)dogModel.Gender;
         foundDog.MicrochipNumber = dogModel.MicrochipNumber;
         foundDog.RabiesTagNumber = dogModel.RabiesTagNumber;
         foundDog.Fixed           = dogModel.Fixed;
         foundDog.Modified        = DateTime.UtcNow;
         using (ITransaction transaction = session.BeginTransaction()) //  Begin a transaction
         {
             session.Update(foundDog);                                 //  Save the user in session
             transaction.Commit();                                     //  Commit the changes to the database
         }
     }
     return(true);
 }
예제 #15
0
 public override void Init(DogModel model, bool friend)
 {
     base.Init(model, friend);
     //赋值队伍信息
     check.SetTeam(Model.Team);
     isFriend = GameData.myControl.Model.Team == Model.Team;
 }
예제 #16
0
 /// <summary>
 /// 开启定时任务:30秒之后产生小兵
 /// </summary>
 public void spawnDog()
 {
     this.StartSchedule(DateTime.UtcNow.AddSeconds(10), delegate
     {
         List <DogModel> dogs = new List <DogModel>();
         for (int i = 0; i < 1; i++)
         {
             //初始化小兵的数据
             // 队伍1 小兵ID: -1000
             DogModel team1Dog = getDogModel(indexTeam1, DogData.Remote, 1);
             team1DogModel.Add(indexTeam1, team1Dog);
             indexTeam1--;
             // 队伍2 小兵ID: -2000
             DogModel team2Dog = getDogModel(indexTeam2, DogData.Remote, 2);
             team2DogModel.Add(indexTeam2, team2Dog);
             indexTeam2--;
             dogs.Add(team1Dog);
             dogs.Add(team2Dog);
         }
         //给 客户端发送 现在出兵了 发送的参数就是dogs
         Brocast(OpCode.FightCode, OpFight.DogEnter, 0, "出小兵啦", null, JsonMapper.ToJson(dogs));
         //自身调用自身 无限递归
         spawnDog();
     });
 }
 public void AddDogToCustomer(DogModel dModel, CustomerModel cModel)
 {
     using (IDbConnection connection = new System.Data.SQLite.SQLiteConnection(GlobalConfig.CnnString(db)))
     {
         connection.Query("INSERT INTO customer_to_dog (customerId, dogId) VALUES (" + cModel.Id + " ," + dModel.Id + ")");
     }
 }
        public DogModel AddDogToDatabase(DogModel dModel)
        {
            using (IDbConnection connection = new System.Data.SQLite.SQLiteConnection(GlobalConfig.CnnString(db)))
            {
                dModel.Id = connection.Query <int>(@"INSERT INTO Dog (name, breed, color, gender, birthday,permanentcastrated, castratedsince, effectiveuntil, create_date, edit_date, active) VALUES(@Name, @Breed, @Color, @Gender, @Birthday, @PermanentCastrated, @CastratedSince, @EffectiveUntil, datetime('now'), null, 1 ); SELECT last_insert_rowid();", dModel).First();
                if (dModel.Diseases != null && dModel.Diseases.Count > 0)
                {
                    foreach (DiseasesModel disModel in dModel.Diseases)
                    {
                        disModel.Id = connection.Query <int>(@"INSERT INTO diseases (name, active) VALUES(@name, 1); SELECt last_insert_rowid()", disModel).First();
                        connection.Query("INSERT INTO dog_to_diseases (dogId, diseasesId) VALUES(" + dModel.Id + " ," + disModel.Id + ")");
                    }
                }

                if (dModel.Characteristics != null && dModel.Characteristics.Count > 0)
                {
                    foreach (CharacteristicsModel chaModel in dModel.Characteristics)
                    {
                        chaModel.Id = connection.Query <int>(@"INSERT INTO characteristics (description, active) VALUES (@Description, 1); SELECT last_insert_rowid()", chaModel).First();
                        connection.Query("INSERT INTO dog_to_characteristics (dogId, characteristicsId) VALUES(" + dModel.Id + " , " + chaModel.Id + ")");
                    }
                }
            }

            return(dModel);
        }
예제 #19
0
        public void Update_CreatedUpdateAndRead1Record_UpdatedValues()
        {
            //Assemble
            DogModel dogModel = new DogModel();

            dogModel.name     = "Ted";
            dogModel.clientID = clientId;
            dogModel.age      = 8;
            dogModel.breed    = "Shi Tzu";
            dogModel.experienceOrQualification = false;
            DogTable dogTable = new DogTable();
            int      dogID    = dogTable.create(dogModel);

            dogModel.id       = dogID;
            dogModel.clientID = clientId;
            dogModel.name     = "Coco";
            dogModel.age      = 17;
            dogModel.breed    = "Yorkshire Terrier";
            dogModel.experienceOrQualification = true;

            //Act
            dogTable.update(dogModel);
            DogModel actual = dogTable.read(dogID);

            //Assert
            Assert.AreEqual(dogModel.name, actual.name);
            Assert.AreEqual(dogModel.clientID, actual.clientID);
            Assert.AreEqual(dogModel.age, actual.age);
            Assert.AreEqual(dogModel.breed, actual.breed);
            Assert.AreEqual(dogModel.experienceOrQualification, actual.experienceOrQualification);
        }
예제 #20
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //If this is 0 then there is nothing to show. The model is blank
            if (selectedDog.id == 0)
            {
                return;
            }

            //Don't let them delete it by accident
            DialogResult result = MessageBox.Show(
                "Wow!! Wait...are you sure?",
                "Important Question",
                MessageBoxButtons.YesNo);

            //Abort!!
            if (result == DialogResult.No)
            {
                return;
            }

            //Delete the reord from the table and update the ListView
            try
            {
                new DogTable().delete(selectedDog.id);

                //reset everything
                ClearInputs();
                RefreshList();
                selectedDog = new DogModel();
            }
            catch (Exception ex)
            {
                new ExceptionMessageGenerator().generateMessage(ex.Message);
            }
        }
예제 #21
0
 static public bool ValidateUpdateDog(DogModel updatedDog)
 {
     if (!ValidateDogDateOfBirth(updatedDog.DateOfBirth))
     {
         return(false);
     }
     return(true);
 }
        public DogModel AddDog(DogModel dModel, CustomerModel cModel)
        {
            AddDogToDatabase(dModel);
            AddDogToCustomer(dModel, cModel);
            Get_Customer(cModel);

            return(dModel);
        }
예제 #23
0
        protected override async Task OnInitializedAsync()
        {
            var myDog = await Client.GetDefaultDog();

            DogModel   = new DogModel(myDog);
            Model.Dog  = DogModel;
            FoodModels = await Client.GetAllFood();
        }
예제 #24
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (cbxClient.Text == PLEASE_SELECT)
            {
                MessageBox.Show("Please select a client's name", "Missing input");
                return;
            }

            if (rbtnYes.Checked == false && rbtnNo.Checked == false)
            {
                MessageBox.Show("Please select a level of experience", "Missing input");
                return;
            }

            if (new InputCheckMessageBox().checkInputIsInt(txtAge.Text, lblAge.Text) == false)
            {
                return;
            }

            try
            {
                //fill up the model with all the input fields
                selectedDog.clientID = (cbxClient.SelectedItem as dynamic).Value;
                //Convert.ToInt32(cbxClient.SelectedItem);
                selectedDog.name  = txtName.Text;
                selectedDog.age   = Convert.ToInt32(txtAge.Text);
                selectedDog.breed = txtBreed.Text;
                if (rbtnYes.Checked)
                {
                    selectedDog.experienceOrQualification = true;
                }
                if (rbtnNo.Checked)
                {
                    selectedDog.experienceOrQualification = false;
                }


                //The id will be 0 if New button was clicked
                if (selectedDog.id == 0)
                {
                    new DogTable().create(selectedDog);
                }
                else
                {
                    new DogTable().update(selectedDog);
                }

                //reset everything
                ClearInputs();
                RefreshList();
                selectedDog = new DogModel();
            }
            catch (Exception ex)
            {
                String message = new ExceptionMessageGenerator().generateMessage(ex.Message);
                MessageBox.Show(message);
            }
        }
예제 #25
0
        protected override async Task OnInitializedAsync()
        {
            var myDog = await Client.GetDefaultDog();

            DogModel = new DogModel(myDog);
            var healthData = await Client.GetAllHealth();

            HealthModels = healthData;
        }
예제 #26
0
        protected override async Task OnInitializedAsync()
        {
            var myDog = await Client.GetDefaultDog();

            DogModel       = new DogModel(myDog);
            BoardingModels = await Client.GetAllBoarding();

            DialogService.OnClose += (res) => Close(res);
        }
        /// <summary>
        /// Constructor initializes everything
        /// </summary>
        /// <param name="dog"></param>
        public DogDetailsViewModel(DogModel dog)
        {
            DogToEdit = dog;
            DogName   = DogToEdit.Name;
            Breed     = DogToEdit.Breed;
            Color     = DogToEdit.Color;
            Gender.Add("Weibchen");
            Gender.Add("Rüde");
            SelectedGender = DogToEdit.Gender;
            Birthday       = Convert.ToDateTime(DogToEdit.Birthday);

            if (DogToEdit.PermanentCastrated)
            {
                CastratedSince      = Convert.ToDateTime(DogToEdit.CastratedSince);
                EffectiveUntil      = DateTime.Now;
                CastrationIsDurable = true;
                PermanentCastrated  = true;
            }
            else
            {
                if (DogToEdit.EffectiveUntil != null)
                {
                    EffectiveUntil = Convert.ToDateTime(DogToEdit.EffectiveUntil);
                    CastratedSince = DateTime.Now;
                }
                else
                {
                    EffectiveUntil = DateTime.Now;
                }
                CastrationIsDurable    = false;
                CastrationIsNotDurable = true;
                PermanentCastrated     = false;
            }

            if (DogToEdit.Diseases != null && DogToEdit.Diseases.Count > 0)
            {
                DiseasesList = new BindableCollection <DiseasesModel>(DogToEdit.Diseases);
            }
            if (DogToEdit.Characteristics != null && DogToEdit.Characteristics.Count > 0)
            {
                CharacteristicsList = new BindableCollection <CharacteristicsModel>(DogToEdit.Characteristics);
            }
            if (DogToEdit.Active == 1)
            {
                NotActive = false;
            }
            else
            {
                NotActive = true;
            }
            DogToEdit.CustomerList = GlobalConfig.Connection.GetAllCustomerForDog(DogToEdit);
            if (DogToEdit.CustomerList != null && DogToEdit.CustomerList.Count > 0)
            {
                Owner = new BindableCollection <CustomerModel>(DogToEdit.CustomerList);
            }
            NotifyOfPropertyChange(() => Owner);
        }
예제 #28
0
 public DogProfileBase()
 {
     Model = new DogModel();
     //NotificationService = new NotificationService();
     Genders = Enum.GetValues(typeof(Gender)).Cast <Gender>().Select(x => new GenderModel()
     {
         Name = x.ToString(), Value = (int)x
     });
 }
예제 #29
0
        public DogsPage()
        {
            InitializeComponent();

            BindingTest      = new DogModel();
            BindingTest.Name = "Frank";

            BindingContext = BindingTest;
        }
예제 #30
0
        public void ReadAll_Create3Records_3DifferentRecords()
        {
            //Assemble
            DogModel dogModel1 = new DogModel();

            dogModel1.name     = "Ted";
            dogModel1.clientID = clientId;
            dogModel1.age      = 8;
            dogModel1.breed    = "Shi Tzu";
            dogModel1.experienceOrQualification = false;

            DogModel dogModel2 = new DogModel();

            dogModel2.name     = "Ted 2";
            dogModel2.clientID = clientId;
            dogModel2.age      = 82;
            dogModel2.breed    = "Shi Tzu 2";
            dogModel2.experienceOrQualification = true;

            DogModel dogModel3 = new DogModel();

            dogModel3.name     = "Ted 3";
            dogModel3.clientID = clientId;
            dogModel3.age      = 83;
            dogModel3.breed    = "Shi Tzu 3";
            dogModel3.experienceOrQualification = false;

            DogTable dogTable = new DogTable();

            //Act
            int             dogID1 = dogTable.create(dogModel1);
            int             dogID2 = dogTable.create(dogModel2);
            int             dogID3 = dogTable.create(dogModel3);
            List <DogModel> actual = dogTable.readAll();

            //Assert
            Assert.AreEqual(dogID1, dogID1);
            Assert.AreEqual(dogModel1.name, actual[0].name);
            Assert.AreEqual(dogModel1.clientID, actual[0].clientID);
            Assert.AreEqual(dogModel1.age, actual[0].age);
            Assert.AreEqual(dogModel1.breed, actual[0].breed);
            Assert.AreEqual(dogModel1.experienceOrQualification, actual[0].experienceOrQualification);

            Assert.AreEqual(dogID2, dogID2);
            Assert.AreEqual(dogModel2.name, actual[1].name);
            Assert.AreEqual(dogModel2.clientID, actual[1].clientID);
            Assert.AreEqual(dogModel2.age, actual[1].age);
            Assert.AreEqual(dogModel2.breed, actual[1].breed);
            Assert.AreEqual(dogModel2.experienceOrQualification, actual[1].experienceOrQualification);

            Assert.AreEqual(dogID3, dogID3);
            Assert.AreEqual(dogModel3.name, actual[2].name);
            Assert.AreEqual(dogModel3.clientID, actual[2].clientID);
            Assert.AreEqual(dogModel3.age, actual[2].age);
            Assert.AreEqual(dogModel3.breed, actual[2].breed);
            Assert.AreEqual(dogModel3.experienceOrQualification, actual[2].experienceOrQualification);
        }