public void TestAddCitizen()
        {
            ITatooineCitizens _Service = new TatooineCitizens(repository);

            Citizens cit = new Citizens();
            cit.Name = "Test";
            cit.IdStatus = 1;
            cit.Specie = "test";
            Assert.IsTrue(_Service.AddCitizen(cit) > 0);
        }
 public long AddCitizen(Citizens Citizen)
 {
     try
     {
         return repository.AddCitizen(Citizen);
     }
     catch (Exception ex)
     {
         LogUtil.Log("AddCitizen", ex);
         throw new FaultException(ex.Message);
     }
 }
Exemplo n.º 3
0
        protected void btAdd_Click(object sender, EventArgs e)
        {
            if(Page.IsValid)
            {
                long IdCitizen = 0;
                string action = "saved";
                try
                {
                    Citizens cit = new Citizens();
                    cit.Name = tbName.Text;
                    cit.Specie = tbSpecie.Text;
                    cit.IdRole = int.Parse(ddlRol.SelectedValue);

                    if (string.IsNullOrEmpty(hdId.Value))
                    {
                        cit.IdStatus = 1;
                        action = "added";
                        WCFproxy<ITatooineCitizens>.Use(client =>
                        {
                            IdCitizen = client.AddCitizen(cit);
                        });
                    }
                    else
                    {
                        cit.Id = long.Parse(hdId.Value);
                        cit.IdStatus  = int.Parse(ddlStatus.SelectedValue);
                        WCFproxy<ITatooineCitizens>.Use(client =>
                        {
                           var result = client.UpdateCitizen(cit);
                           if (result)
                               IdCitizen = cit.Id;

                        });
                    }
                }
                catch (Exception ex)
                {
                    LogUtil.Log("Error btSave_Click Register.aspx", ex);
                }
                if(IdCitizen>0)
                {
                    BlockUI();
                    lbSuccessMessage.Text = "Citizen " + action + " successfully.";
                    lbErrorMessage.Visible = false;
                    LogUtil.Log("Citizen "+ action+" successfully." + IdCitizen.ToString());
                }
                else
                {
                    lbErrorMessage.Text = "Error saving Citizen. Please try again.";
                }
            }
        }
        public void TestDeleteCitizen()
        {
            var repository = new TatooineRepository.Fakes.StubITattoineCitizensRepository()
             {
                 DeleteCitizenString = (Citizens) =>
                 {
                     return true;
                 }
             };
             ITatooineCitizens _Service = new TatooineCitizens(repository);

             Citizens cit = new Citizens();
             cit.Id  = 1;

             Assert.IsTrue(_Service.DeleteCitizen(cit.Id.ToString()));
        }
        public void TestAddCitizen()
        {
            var repository = new TatooineRepository.Fakes.StubITattoineCitizensRepository()
            {
                AddCitizenCitizens = (Citizens) =>
                {
                    return 1;
                }
            };
            ITatooineCitizens _Service = new TatooineCitizens(repository);

            Citizens cit = new Citizens();
            cit.Name = "Test";
            cit.IdStatus = 1;
            cit.Specie = "test";
            Assert.IsTrue(_Service.AddCitizen(cit) > 0);
        }
 public bool UpdateCitizen(Citizens Citizen)
 {
     try
     {
         return repository.UpdateCitizen(Citizen);
     }
     catch (Exception ex)
     {
         LogUtil.Log("UpdateCitizen", ex);
         throw new FaultException(ex.Message);
     }
 }