コード例 #1
0
ファイル: Detail.aspx.cs プロジェクト: robgray/Tucana
        protected void lnkSave_Click(object sender, EventArgs e)
        {
            int agentId = 0;
            Agent agent;
            if (int.TryParse(hdnAgentId.Value, out agentId))
            {
                agent = new Agent(agentId);
            }
            else
            {
                agent = new Agent();
            }

            agent.AgentName = txtAgent.Text;
            if (!string.IsNullOrEmpty(txtCommission.Text)) agent.CommissionPercent = decimal.Parse(txtCommission.Text);
            agent.Email = txtEmail.Text;
            agent.Address = new Address
                                {
                                    Street = AgentAddress.Street,
                                    Suburb = AgentAddress.Suburb,
                                    State = AgentAddress.State,
                                    Postcode = AgentAddress.Postcode
                                };

            try
            {
                var response = AgentService.SaveAgent(new SaveAgentRequest { Agent = agent });
                if (response.IsSuccessful)
                {
                    UserMessage.SetSuccess("Agent saved");
                }
                else
                {
                    UserMessage.SetFailure("Failed to save Agent: " + response.Message);
                }
            }
            catch (Exception)
            {
                CurrentSession.ExceptionMessage = "Unable to save Agent.";
                throw;
            }
        }
コード例 #2
0
ファイル: AgentRepository.cs プロジェクト: robgray/Tucana
        private AirtimeBilling.Core.Entities.Agent PopulateAgentEntity(Agent agent)
        {
            AirtimeBilling.Core.Entities.Agent entity = null;

            if (agent != null)
            {
                var address = new Address
                                  {
                                      Street = agent.Street,
                                      Suburb = agent.Suburb,
                                      State = agent.State,
                                      Postcode = agent.Postcode
                                  };

                entity = new AirtimeBilling.Core.Entities.Agent(agent.AgentId)
                {
                    AgentName = agent.AgentName,
                    Address = address,
                    Email = agent.Email,
                    CommissionPercent = (decimal)agent.CommissionPercent
                };
            }
            return entity;
        }