public DealershipEntity ToDealershipEntity(DealershipSummary d)
        {
            var ret = new DealershipEntity
            {
                Id   = d.Id,
                Name = d.Name,
                Cnpj = d.Cnpj,
                AgreementLetterSent = d.AgreementLetterSent,
            };

            return(ret);
        }
Exemplo n.º 2
0
        public DealershipEntity ToDealershipEntity(DealershipCreate vm)
        {
            var entity = new DealershipEntity
            {
                Id = vm.Id,
                //Name = vm.Name,
                //Cnpj = vm.Cnpj,
                AgreementLetterSent = vm.AgreementLetterSent
            };

            return(entity);
        }
        public List <DealershipEntity> ToDealershipEntity(List <DealershipSummary> list)
        {
            var collection = new List <DealershipEntity>();

            foreach (var l in list)
            {
                var ret = new DealershipEntity
                {
                    Id   = l.Id,
                    Name = l.Name,
                    Cnpj = l.Cnpj,
                    AgreementLetterSent = l.AgreementLetterSent,
                };
            }

            return(collection);
        }
        public bool Register(int campaignId, DealershipEntity dealership)
        {
            var relatedCampaign = incentiveCampaignApl.GetById(campaignId);

            var dealershipsOnCampaign = dealershipDb.ReadByCampaign(campaignId);

            if (dealershipsOnCampaign.Contains(dealership))
            {
                throw new Exception("Dealership.Already.Registered");
            }

            if (relatedCampaign == null)
            {
                throw new Exception("Campaign.Does.Not.Exists");
            }

            return(dealershipDb.Register(campaignId, dealership));
        }
Exemplo n.º 5
0
        //TODO: Testar
        public bool Register(int campaignId, DealershipEntity dealership)
        {
            try
            {
                var sql = "spr_digit_ins_campa_incen_conce";

                using (var cmd = new SqlCommand(sql, connection))
                {
                    cmd.Parameters.AddWithValue("@num_campa_incen", campaignId);
                    cmd.Parameters.AddWithValue("@num_entid_conce", dealership.Id);

                    var datareader = cmd.ExecuteReader();
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 6
0
        public bool Register(int campaignId, DealershipEntity dealership)
        {
            try
            {
                this.connector.Procedure = "spr_digit_ins_refac_campa_incen_conce";

                this.connector.AddParameter("num_campa_incen", campaignId);
                this.connector.AddParameter("num_entid_conce", dealership.Id);
                this.connector.AddParameter("ind_carta_acord", dealership.AgreementLetterSent);

                this.connector.ExecuteReader();

                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                this.connector.Dispose();
            }
        }
Exemplo n.º 7
0
        // usado para montar o objeto de campanha ao editar uma campanha
        public List <DealershipEntity> ReadByCampaign(int campaignId)
        {
            try
            {
                this.connector.Procedure = "spr_digit_ler_refat_campa_incen_conce_por_campa";
                this.connector.AddParameter("@num_campa_incen", campaignId);

                using (var reader = this.connector.ExecuteReader())
                {
                    var campaigns = new List <DealershipEntity>();

                    while (reader.Read())
                    {
                        var c = new DealershipEntity
                        {
                            Id   = Convert.ToInt32(reader["num_entid_conce"]),
                            Name = reader["nom_campa_incen"].ToString(),
                            Cnpj = reader["cnpj_cpf_entid_conce"].ToString(),
                            AgreementLetterSent = Convert.ToBoolean(reader["ind_carta_acord"])
                                                  //Dealers
                        };

                        campaigns.Add(c);
                    }

                    return(campaigns);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                this.connector.Dispose();
            }
        }
Exemplo n.º 8
0
        public DealershipEntity ReadById(int dealershipId)
        {
            try
            {
                this.connector.Procedure = "spr_digit_ler_refat_campa_incen_conce_por_id";
                this.connector.AddParameter("@num_campa_incen_usuar", dealershipId);

                using (var reader = this.connector.ExecuteReader())
                {
                    var campaigns = new DealershipEntity();

                    while (reader.Read())
                    {
                        var c = new DealershipEntity
                        {
                            Id   = Convert.ToInt32(reader["num_campa_incen"]),
                            Name = reader["nom_campa_incen"].ToString(),
                            Cnpj = reader["cnpj_cpf_entid_conce"].ToString(),
                            AgreementLetterSent = Convert.ToBoolean(reader["cnpj_cpf_entid_conce"])
                                                  //Dealers
                        };

                        return(c);
                    }
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                this.connector.Dispose();
            }
        }
Exemplo n.º 9
0
 public DealershipEntity Create(int campaignId, DealershipEntity incentiveCampaign)
 {
     throw new NotImplementedException();
 }