コード例 #1
0
 public PartnerViewModel(PartnerDTO t, string editUrl)
 {
     PartnerId             = t.PartnerId;
     NucleoId              = t.NucleoId;
     Name                  = t.Name;
     EnterpriseContributor = t.EnterpriseContributor;
     PrivateContributor    = t.PrivateContributor;
     ContributionTypeId    = t.ContributionTypeId;
     PartnershipTypeId     = t.PartnershipTypeId;
     ContactPerson         = t.ContactPerson;
     Department            = t.Department;
     Phone                 = t.Phone;
     Email                 = t.Email;
     Iban                  = t.Iban;
     BicSwift              = t.BicSwift;
     FiscalNumber          = t.FiscalNumber;
     Latitude              = t.Latitude;
     Longitude             = t.Longitude;
     PhotoUrl              = t.PhotoUrl;
     AddressId             = t.AddressId;
     PartnershipStartDate  = t.PartnershipStartDate;
     DurationCommitment    = t.DurationCommitment;
     RefoodAreaInteraction = t.RefoodAreaInteraction;
     Reliability           = t.Reliability;
     InteractionFrequency  = t.InteractionFrequency;
     Active                = t.Active;
     IsDeleted             = t.IsDeleted;
     CreateBy              = t.CreateBy;
     CreateOn              = t.CreateOn;
     UpdateBy              = t.UpdateBy;
     UpdateOn              = t.UpdateOn;
     EditUrl               = editUrl;
 }
コード例 #2
0
        public bool Apply(string name, int storeId)
        {
            var partner = new PartnerDTO();
            var user    = _user.GetByName(name).Result;
            var store   = _store.FindByID(storeId);

            partner.ModifiedDate = DateTime.Now;
            partner.UseID        = user.ID;
            partner.StoreID      = storeId;
            partner.CreatedDate  = DateTime.Now;
            partner.isWorking    = false;
            if (_repo.Apply(partner.Translate <PartnerDTO, Partner>()) != null)
            {
                var mess = new Message();
                mess.CreatedDate = DateTime.Now;
                mess.DataID      = storeId;
                mess.Description = user.UserName + " just applied to your store " + store.Name;
                mess.IsRead      = false;
                mess.MessageType = MESS_PARTNER;
                mess.SentID      = store.UserID;
                mess.FromID      = user.ID;
                _mess.CreateMessage(mess);
                return(true);
            }
            return(false);
        }
コード例 #3
0
        private PartnerDTO Create(PartnerViewModel viewModel)
        {
            try
            {
                log.Debug(PartnerViewModel.FormatPartnerViewModel(viewModel));

                PartnerDTO partner = new PartnerDTO();

                // copy values
                viewModel.UpdateDTO(partner, null); //RequestContext.Principal.Identity.GetUserId());

                // audit
                partner.CreateBy = null; //RequestContext.Principal.Identity.GetUserId();
                partner.CreateOn = DateTime.UtcNow;

                // add
                log.Debug("_partnerService.AddPartner - " + PartnerDTO.FormatPartnerDTO(partner));

                int id = _partnerService.AddPartner(partner);

                partner.PartnerId = id;

                log.Debug("result: 'success', id: " + id);

                return(partner);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
コード例 #4
0
        public IActionResult GenerateJSONWebTokenauth(PartnerDTO userInfo)
        {
            IActionResult response    = Unauthorized();
            var           securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"]));
            var           credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);

            var AppIDKey        = _config["Jwt:APPID"];
            var ClientSecretKey = _config["Jwt:CLIENTSECRET"];

            var claims = new[] {
                new Claim(JwtRegisteredClaimNames.Sub, "DKBS"),
                new Claim("APPID", AppIDKey.ToString()),
                new Claim("ClientSecret", ClientSecretKey.ToString())
            };

            var token = new JwtSecurityToken(_config["Jwt:Issuer"],
                                             _config["Jwt:Issuer"],
                                             claims,
                                             expires: DateTime.Now.AddMinutes(120),
                                             signingCredentials: credentials);


            var tokenString = token;

            response = Ok(new { token = tokenString });
            return(response);
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <PartnerDTO> GetPartners()
        {
            List <PartnerDTO> retVal = new List <PartnerDTO>();

            try
            {
                DataSet ds = new ProjectDB(Utility.ConfigurationHelper.GPD_Connection).GetPartners();
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        PartnerDTO tempPartnerDTO = new PartnerDTO();
                        tempPartnerDTO.partnerId        = dr["partner_id"].ToString();
                        tempPartnerDTO.Name             = dr["name"].ToString();
                        tempPartnerDTO.URL              = dr["site_url"].ToString();
                        tempPartnerDTO.ShortDescription = dr["short_description"].ToString();
                        tempPartnerDTO.Description      = dr["description"].ToString();
                        tempPartnerDTO.IsActive         = Convert.ToBoolean(dr["active"]);
                        retVal.Add(tempPartnerDTO);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Unable to get partners", ex);
            }
            return(retVal);
        }
コード例 #6
0
        public void GetPartnersPaged_Success_Test()
        {
            // Arrange
            string searchTerm = "";
            int    pageIndex  = 0;
            int    pageSize   = 10;

            // list
            IList <R_Partner> list = new List <R_Partner>();

            for (int i = 1; i <= pageSize; i++)
            {
                list.Add(SamplePartner(i));
            }

            // create mock for repository
            var mock = new Mock <IPartnerRepository>();

            mock.Setup(s => s.GetPartners(Moq.It.IsAny <string>(), Moq.It.IsAny <int>(), Moq.It.IsAny <int>())).Returns(list);

            // service
            PartnerService partnerService = new PartnerService();

            PartnerService.Repository = mock.Object;

            // Act
            var        resultList = partnerService.GetPartners(searchTerm, pageIndex, pageSize);
            PartnerDTO result     = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.PartnerId);
            Assert.AreEqual(10, resultList.Count);
        }
コード例 #7
0
        public int AddPartner(PartnerDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(PartnerDTO.FormatPartnerDTO(dto));

                R_Partner t = PartnerDTO.ConvertDTOtoEntity(dto);

                // add
                id            = Repository.AddPartner(t);
                dto.PartnerId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
コード例 #8
0
        public void GetPartners_Success_Test()
        {
            // Arrange
            R_Partner partner = SamplePartner(1);

            IList <R_Partner> list = new List <R_Partner>();

            list.Add(partner);

            // create mock for repository
            var mock = new Mock <IPartnerRepository>();

            mock.Setup(s => s.GetPartners()).Returns(list);

            // service
            PartnerService partnerService = new PartnerService();

            PartnerService.Repository = mock.Object;

            // Act
            var        resultList = partnerService.GetPartners();
            PartnerDTO result     = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.PartnerId);
        }
コード例 #9
0
        public PartnerDTO GetPartner(int partnerId)
        {
            try
            {
                //Requires.NotNegative("partnerId", partnerId);

                log.Debug("partnerId: " + partnerId + " ");

                // get
                R_Partner t = Repository.GetPartner(partnerId);

                PartnerDTO dto = new PartnerDTO(t);

                log.Debug(PartnerDTO.FormatPartnerDTO(dto));

                return(dto);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
コード例 #10
0
 public ActionResult Create(PartnerDTO partner)
 {
     try
     {
         if (partner.FileImage != null)
         {
             partner.PartnerImage = DateTime.Now.Ticks + partner.PartnerImage + ".png";
             partner.FileImage.SaveAs(Server.MapPath(path + partner.PartnerImage));
             partner.FileImage = null;
         }
         else
         {
             partner.PartnerImage = "default.png";
         }
         var data = ApiService.CreatePartner(partner);
         if (data != null)
         {
             return(RedirectToAction("Index"));
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(RedirectToAction("Index"));
     }
 }
コード例 #11
0
 public AddPropertyPictureResult AddPropertyPicture(PartnerDTO partner, Guid propertyId, PropertyPictureDTO picture)
 {
     Connector.IsTransaction = true;
     try
     {
         PropertyBLL propertyBLL = new PropertyBLL(Connector);
         PropertyDTO property    = propertyBLL.ReadById(propertyId);
         if (property.Partner.Id == partner.Id)
         {
             PropertyPictureBLL pictureBLL = new PropertyPictureBLL(Connector);
             picture.Property = property;
             PropertyPictureBLL.CreateResult result = pictureBLL.Create(picture);
             if (result == PropertyPictureBLL.CreateResult.OK)
             {
                 Connector.CommitTransaction();
             }
             else
             {
                 Connector.RollbackTransaction();
             }
             return((AddPropertyPictureResult)(byte)result);
         }
         else
         {
             return(AddPropertyPictureResult.NotFound);
         }
     }
     catch (Exception exception)
     {
         Connector.RollbackTransaction();
         throw exception;
     }
 }
コード例 #12
0
        //Delete sender code document
        public static bool DeleteSenderCodeDocument(string filePath, int ClientId)
        {
            try
            {
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                    ClientDTO ClientDTO = new ClientDTO();
                    ClientDTO = GetById(ClientId);
                    ClientDTO.SenderCodeFilePath = null;

                    GlobalSettings.LoggedInClientId = ClientDTO.Id;
                    int PartnerId = ClientService.GetById(ClientDTO.Id).PartnerId;
                    GlobalSettings.LoggedInPartnerId = PartnerId;

                    Edit(ClientDTO);

                    // Send Mail to Admin
                    PartnerDTO PartnerDTO = new PartnerDTO();
                    PartnerDTO = PartnerService.GetById(ClientDTO.PartnerId);
                    CommonService.SendEmail("Removed sendercode application request", "<HTML><BODY><P>Hello " + CommonService.GetFirstname(PartnerDTO.Name) + "</P><P>Request for sender code from " + ClientDTO.Company + " has been removed.</P></BODY></HTML>", PartnerDTO.Email, "", false);

                    return(true);
                }

                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #13
0
 public bool UpdatePartner(PartnerDTO partner)
 {
     if (new PartnerBus().UpdatePartner(partner))
     {
         return(true);
     }
     return(false);
 }
コード例 #14
0
        private void btnSacuvaj_Click(object sender, EventArgs e)
        {
            PartnerDTO partner = fillObject();

            VeleprodajaUtil.getDAOFactory().getPartnerDAO().insert(partner);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
コード例 #15
0
 public IHttpActionResult UpdatePartner(PartnerDTO partner)
 {
     if (new Repositories().UpdatePartner(partner))
     {
         return(Ok());
     }
     return(InternalServerError());
 }
コード例 #16
0
        public AddPropertyResult AddProperty(PartnerDTO partner, PropertyDTO property)
        {
            PropertyBLL propertyBLL = new PropertyBLL(Connector);

            property.Partner = partner;
            PropertyBLL.CreateResult result = propertyBLL.Create(property);
            return((AddPropertyResult)(byte)result);
        }
コード例 #17
0
        public static PartnerDTO readerToPartnerDTO(MySqlDataReader reader)
        {
            PartnerDTO partner = new PartnerDTO();

            partner.Jib    = reader.GetString("JIB");
            partner.Adresa = reader["Adresa"].ToString();
            partner.Naziv  = reader["Naziv"].ToString();
            return(partner);
        }
コード例 #18
0
        private PartnerDTO fillObject()
        {
            PartnerDTO partner = new PartnerDTO();

            partner.Jib    = tbxJib.Text;
            partner.Naziv  = tbxNaziv.Text;
            partner.Adresa = tbxAdresa.Text;
            partner.Mjesto = (MjestoDTO)cbMjesto.Items[cbMjesto.SelectedIndex];
            return(partner);
        }
コード例 #19
0
        public static PartnerDTO PartnerToDTO(Partner Partner)
        {
            if (Partner == null)
            {
                return(null);
            }
            Mapper.CreateMap <Partner, PartnerDTO>();
            PartnerDTO PartnerDTO = Mapper.Map <PartnerDTO>(Partner);

            return(PartnerDTO);
        }
コード例 #20
0
ファイル: PartnerUnitTest.cs プロジェクト: HatunSearch/NET
        public void CreateAPartnerAccountWithAnAlreadyUsedUsername()
        {
            PartnerBLL partnerBLL = new PartnerBLL(TestApp.Connector);
            CountryDTO country    = new CountryDTO()
            {
                Id = "PE"
            };
            DistrictDTO district = new DistrictDTO()
            {
                Country  = country,
                Code     = "150106",
                Province = new ProvinceDTO()
                {
                    Country = country,
                    Code    = "150100",
                    Region  = new RegionDTO()
                    {
                        Country = country,
                        Code    = "150000"
                    }
                }
            };
            PartnerDTO partner = new PartnerDTO()
            {
                Username   = "******",
                Password   = new byte[64],
                FirstName  = "Aldo",
                MiddleName = "Alejandro",
                LastName   = "Astupillo Cáceres",
                Gender     = new GenderDTO()
                {
                    Id = "M"
                },
                EmailAddress      = "*****@*****.**",
                MobileNumber      = "+51989637468",
                CompanyName       = "Hatun Search",
                Address           = "Av. Larco 322",
                Country           = country,
                District          = district,
                PhoneNumber       = "+5115474849",
                Website           = "https://hatunsearch.me",
                PreferredCurrency = new CurrencyDTO()
                {
                    Id = "PEN"
                },
                PreferredLanguage = new LanguageDTO()
                {
                    Id = "ES"
                }
            };

            PartnerBLL.SignupResult result = partnerBLL.Signup(partner, "https://partners.hatunsearch.me", "https://partners.hatunsearch.me/es-pe/accounts/signup/verification");
            Assert.AreEqual(PartnerBLL.SignupResult.UsernameAlreadyUsed, result);
        }
コード例 #21
0
        public static Partner PartnerToDomain(PartnerDTO PartnerDTO)
        {
            if (PartnerDTO == null)
            {
                return(null);
            }
            Mapper.CreateMap <PartnerDTO, Partner>();
            Partner Partner = Mapper.Map <Partner>(PartnerDTO);

            return(Partner);
        }
コード例 #22
0
        public AddCardResult AddCard(PartnerDTO partner, string tokenId)
        {
            PartnerCardBLL cardBLL = new PartnerCardBLL(Connector);
            PartnerCardDTO card    = new PartnerCardDTO()
            {
                Partner  = partner,
                StripeId = tokenId
            };

            PartnerCardBLL.CreateResult result = cardBLL.Create(card);
            return((AddCardResult)(byte)result);
        }
コード例 #23
0
 public ActionResult Update(PartnerDTO partner)
 {
     try
     {
         //get Image have exist
         var currentFileName = ApiService.GetPartnerById(partner.ID).PartnerImage;
         //check name have deafault if exist ==> dont delete
         if (currentFileName == "default.png")
         {
             if (partner.FileImage != null)
             {
                 partner.PartnerImage = DateTime.Now.Ticks + partner.PartnerImage + ".png";
                 partner.FileImage.SaveAs(Server.MapPath(path + partner.PartnerImage));
                 partner.FileImage = null;
             }
             else
             {
                 partner.PartnerImage = "default.png";
             }
         }
         else
         {
             if (partner.FileImage != null)
             {
                 //delete file
                 var filePath = Server.MapPath(path + currentFileName);
                 if (System.IO.File.Exists(filePath))
                 {
                     System.IO.File.Delete(filePath);
                 }
                 partner.PartnerImage = DateTime.Now.Ticks + partner.PartnerImage + ".png";
                 partner.FileImage.SaveAs(Server.MapPath(path + partner.PartnerImage));
                 partner.FileImage = null;
             }
             else
             {
                 partner.PartnerImage = currentFileName;
             }
         }
         var data = ApiService.UpdatePartner(partner);
         if (data != null)
         {
             return(RedirectToAction("Index"));
         }
         return(RedirectToAction("Edit", new { id = partner.ID }));
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(RedirectToAction("Edit", new { id = partner.ID }));
     }
 }
コード例 #24
0
 public Partner CastToDAL(PartnerDTO a)
 {
     return(new Partner()
     {
         partnerId = a.partnerId,
         req2 = a.req2,
         statusId = a.statusId,
         req1 = a.req1,
         RequestParameter = db.RequestParameters.Where(p => p.requestId == a.req1).FirstOrDefault(),
         RequestParameter1 = db.RequestParameters.Where(p => p.requestId == a.req2).FirstOrDefault(),
         Status = db.Status.Where(p => p.statusId == a.statusId).FirstOrDefault()
     });
 }
コード例 #25
0
 //Get partner information by id
 public static PartnerDTO GetById(int Id)
 {
     try
     {
         UnitOfWork uow = new UnitOfWork();
         Partner Partner = uow.PartnerRepo.GetById(Id);
         PartnerDTO PartnerDTO = Transform.PartnerToDTO(Partner);
         return PartnerDTO;
     }
     catch
     {
         throw;
     }
 }
コード例 #26
0
ファイル: PartnerDao.cs プロジェクト: akakshuki/NgosDonation
 public bool Edit(PartnerDTO partner)
 {
     try
     {
         var data = MapperProfile.MapperConfig().Map <PartnerDTO, Partner>(partner);
         _unitOfWork.PartnerRepository.Edit(data);
         return(_unitOfWork.Commit());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
コード例 #27
0
        public int insert(PartnerDTO partner)
        {
            MySqlConnection connection = ConnectionPool.checkOutConnection();
            MySqlCommand    command    = connection.CreateCommand();

            command.CommandText = qInsert;
            command.Parameters.AddWithValue("jib", partner.Jib);
            command.Parameters.AddWithValue("naziv", partner.Naziv);
            command.Parameters.AddWithValue("adresa", partner.Adresa);
            command.Parameters.AddWithValue("postanskiBroj", partner.Mjesto.PostanskiBroj);
            int rows = command.ExecuteNonQuery();

            ConnectionPool.checkInConnection(connection);
            return(rows);
        }
コード例 #28
0
        public ActionResult SignupStep4(PartnerPreferencesDTO preferences)
        {
            if (ModelState.IsValid)
            {
                PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector)
                {
                    EmailAddressVerificationSubject  = LocalizationProvider["VerifyYourEmailAddress"],
                    EmailAddressVerificationTemplate = LocalizationProvider["EmailVerificationTemplate"]
                };
                PartnerDTO             partner      = new PartnerDTO();
                PartnerCredentialDTO   credential   = Session["Signup$Credential"] as PartnerCredentialDTO;
                PartnerPersonalInfoDTO personalInfo = Session["Signup$PersonalInfo"] as PartnerPersonalInfoDTO;
                PartnerCompanyInfoDTO  companyInfo  = Session["Signup$CompanyInfo"] as PartnerCompanyInfoDTO;
                partner.Join(credential);
                partner.Join(personalInfo);
                partner.Join(companyInfo);
                partner.Join(preferences);
                Uri    requestUrl = Request.Url;
                string baseUrl    = new UriBuilder(requestUrl.Scheme, requestUrl.Host, requestUrl.Port).ToString();
                PartnerBLL.SignupResult result = partnerBLL.Signup(partner, baseUrl, Url.Action("VerifyEmailAddress"));
                switch (result)
                {
                case PartnerBLL.SignupResult.OK:
                    Session["Signup$Preferences"] = preferences;
                    return(RedirectToAction("VerifyEmailAddress"));

                case PartnerBLL.SignupResult.UsernameAlreadyUsed:
                    TempData["Errors"] = new Dictionary <string, string>()
                    {
                        { "Username", result.ToString() }
                    };
                    return(RedirectToAction("SignupStep1"));

                case PartnerBLL.SignupResult.EmailAddressAlreadyUsed:
                    TempData["Errors"] = new Dictionary <string, string>()
                    {
                        { "EmailAddress", result.ToString() }
                    };
                    return(RedirectToAction("SignupStep2"));

                default: return(BadRequest());
                }
            }
            else
            {
                return(BadRequestWithErrors(preferences));
            }
        }
コード例 #29
0
        //Edit partner
        public static void Edit(PartnerDTO PartnerDTO)
        {
            try
            {
                GlobalSettings.LoggedInPartnerId = PartnerDTO.Id;  

                UnitOfWork uow = new UnitOfWork();
                Partner Partner = Transform.PartnerToDomain(PartnerDTO);
                uow.PartnerRepo.Update(Partner);
                uow.SaveChanges();
            }
            catch
            {
                throw;
            }
        }
コード例 #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="partner"></param>
        /// <returns></returns>
        public string AddPartner(PartnerDTO partner)
        {
            string retVal = "";

            try
            {
                new ProjectDB(Utility.ConfigurationHelper.GPD_Connection).AddPartner(partner);
                retVal = "SUCCESS";
            }
            catch (Exception ex)
            {
                log.Error("Unable to Save Partner for partnerId: " + partner.partnerId, ex);
                retVal = "ERROR";
            }
            return(retVal);
        }
        public void UpdatePartner(PartnerDTO pPartnerToUpdate)
        {
             //Se verifica que no haya datos vacios.
            if (pPartnerToUpdate.CollectDay == null
                || pPartnerToUpdate.CollectDomicile == string.Empty
                || pPartnerToUpdate.StarDate == null                          
                || pPartnerToUpdate.DocumentNumber == string.Empty
                || pPartnerToUpdate.DocumentTypeId == 0
                || pPartnerToUpdate.Domicile == string.Empty
                || pPartnerToUpdate.FirstName == string.Empty
                || pPartnerToUpdate.LastName == string.Empty
                || pPartnerToUpdate.Telephone == string.Empty 
                || pPartnerToUpdate.CollectDomicile == string.Empty)            
                throw new BusinessException("Campos de datos obligatorios estan vacios");

           //Obtengo el socio original para modificarle los datos
           Partner mPartnerToUpdate = Mapper.Map<Partner>(this.iPartnerDAO.GetById(pPartnerToUpdate.Id));
        
            if (mPartnerToUpdate.QuotaRegime != pPartnerToUpdate.QuotaRegime)
            {
                mPartnerToUpdate.QuotaRegime = pPartnerToUpdate.QuotaRegime;
                mPartnerToUpdate.QuotaCounter = pPartnerToUpdate.QuotaRegime;
            }
           // validamos que se haya encontrado el cobrador
           if (mPartnerToUpdate == null) throw new System.InvalidOperationException(string.Format("Socio no encontrado", pPartnerToUpdate.Id));

           //validamos que el dni sea unico y no halla otro socio con el mismo dni
           if ((from a in this.iPartnerDAO.GetAll() where a.DocumentNumber == pPartnerToUpdate.DocumentNumber & a.Id != pPartnerToUpdate.Id select a).Count() > 0)
           {
               throw new BusinessException("Ya existe un socio con el dni ingresado, ingrese otro");
           }
           //Si cambio el tipo de documento, se actualiza
           if (pPartnerToUpdate.DocumentTypeId != mPartnerToUpdate.DocumentType.Id)
           {
               mPartnerToUpdate.DocumentType = this.iDocumentTypeDAO.GetById(pPartnerToUpdate.DocumentTypeId);
           }
           //Si cambio el cobrador, se actualiza
           if (pPartnerToUpdate.Officer.Id != mPartnerToUpdate.Officer.Id)
           {
               mPartnerToUpdate.Officer = this.iOfficerDAO.GetById(pPartnerToUpdate.Officer.Id);
           }
           Mapper.Map<PartnerDTO, Partner>(pPartnerToUpdate, mPartnerToUpdate);

           // actualizamos la entidad
           this.iPartnerDAO.Update(mPartnerToUpdate);     
            
        }
        public void CreatePartner(PartnerDTO pPartnerToCreate)
        {
            //Se verifica que no haya datos vacios.
            if (pPartnerToCreate.CollectDay == null
                || pPartnerToCreate.CollectDomicile == string.Empty
                || pPartnerToCreate.StarDate == null                          
                || pPartnerToCreate.DocumentNumber == string.Empty
                || pPartnerToCreate.DocumentTypeId == 0
                || pPartnerToCreate.Domicile == string.Empty
                || pPartnerToCreate.FirstName == string.Empty
                || pPartnerToCreate.LastName == string.Empty
                || pPartnerToCreate.Telephone == string.Empty 
                || pPartnerToCreate.CollectDomicile == string.Empty)            
                throw new BusinessException("Campos de datos obligatorios estan vacios");
            
             //Mapeamos el parametro de entrada de tipo PartnerDTO a Partner
             Partner mNewPartner = Mapper.Map<PartnerDTO, Partner>(pPartnerToCreate);

             //Le asigno al contador del regimen de cuotas el mismo valor del regimen de cuotas
             mNewPartner.QuotaCounter = mNewPartner.QuotaRegime;

             //validamos que el dni sea unico y no halla otro socio con el mismo dni
             if ((from a in this.iPartnerDAO.GetAll() where a.DocumentNumber == pPartnerToCreate.DocumentNumber select a).Count() > 0)
             {
                 throw new BusinessException("Ya existe un socio con el codigo ingresado, ingrese otro");
             }

             //Obtenemos el tipo de documento del socio
             mNewPartner.DocumentType = this.iDocumentTypeDAO.GetById(pPartnerToCreate.DocumentTypeId);

             //Obtenemos el cobrador asignado al socio
             mNewPartner.Officer = this.iOfficerDAO.GetById(pPartnerToCreate.Officer.Id);
             
            // persistimos la informacion 
             this.iPartnerDAO.Create(mNewPartner);                
        }
 public static void UpdatePartner(PartnerDTO pPartnerToUpdate)
 {
     iPartnerSvc.UpdatePartner(pPartnerToUpdate);
 }
 public static void CreatePartner(PartnerDTO pPartner)
 {
     iPartnerSvc.CreatePartner(pPartner);
 }
        private void bUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                OfficerDTO mOfficer = new OfficerDTO
                {
                    Id = Convert.ToInt32(cbOfficer.SelectedValue)
                };
                PartnerDTO mPartner = new PartnerDTO
                {
                    Id = Convert.ToInt32(tbIdPartnerSelected.Text),
                    FirstName = tbFirstName.Text.ToString(),
                    LastName = tbLastName.Text,
                    DocumentTypeId = Convert.ToInt32(cbDocumentType.SelectedValue),
                    DocumentNumber = mtDocumentNumber.Text,
                    Domicile = tbDomicile.Text,
                    Telephone = tbTelephone.Text,
                    Officer = mOfficer,
                    ValueQuota = Convert.ToSingle(tbValueQuota.Text),
                    QuotaRegime = Convert.ToInt32(cbQuotaRegime.SelectedItem.ToString()),
                    CollectDay = cbDel.SelectedValue.ToString() + "-" + cbAl.SelectedValue.ToString(),
                    CollectDomicile = tbCollectDomicile.Text,
                    StarDate = Convert.ToDateTime(tbStartDate.Text)
                };
                PartnerFacade.UpdatePartner(mPartner);
                this.CleanDataRowSelectDataGridView();
                this.LoadDataGridViewPartner();

                MessageBox.Show("Socio modificado satisfactoriamente", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (BusinessException exception)
            {
                if (tbFirstName.Text == "")
                {
                    FirstNameError.Visible = true;
                }
                if (tbLastName.Text == "")
                {
                    LastNameError.Visible = true;
                }
                if (mtDocumentNumber.Text.Length == 10)
                {
                    for (int indice = 0; indice < mtDocumentNumber.Text.Length; indice++)
                    {
                        if (mtDocumentNumber.Text[indice] == ' ')
                        {
                            DocumentNumberError.Visible = true;
                            indice = mtDocumentNumber.Text.Length;
                        }
                    }
                }
                else
                {
                    DocumentNumberError.Visible = true;
                }
                if (tbDomicile.Text == "")
                {
                    DomicileError.Visible = true;
                }
                if (tbTelephone.Text == "")
                {
                    TelephoneError.Visible = true;
                }
                if (tbValueQuota.Text == "")
                {
                    ValueQuotaError.Visible = true;
                }
                if (tbCollectDomicile.Text == "")
                {
                    CollectDomicileError.Visible = true;
                }
                labelMessaError.Visible = true;
                labelMessaError.Text = exception.Message;
            }
            catch (NullReferenceException exception)
            {
                labelMessaError.Visible = true;
                labelMessaError.Text = exception.Message;
            }
            catch (FormatException)
            {
                labelMessaError.Visible = true;
                labelMessaError.Text = "El formato ingresado es invalido";
            }
            catch (InvalidFormatException exception)
            {
                labelMessaError.Visible = true;
                labelMessaError.Text = exception.Message;
            }
            catch (PartnerException exception)
            {
                labelMessaError.Visible = true;
                labelMessaError.Text = exception.Message;
                DocumentNumberError.Visible = true;
            }
            catch (QuotaException exception)
            {
                labelMessaError.Visible = true;
                labelMessaError.Text = exception.Message;
                ValueQuotaError.Visible = true;
            }
            catch (Exception exception)
            {
                labelMessaError.Visible = true;
                labelMessaError.Text = exception.Message;
            }
        }