public DTOResponse <DTOPartner> Create(DTOPartner createInfo) { var model = createInfo.ToModel(); _collection.InsertOne(model); return(new DTOResponse <DTOPartner>() { Code = 200 }); }
public static PartnerModel ToModel(this DTOPartner dto) { int infoStatus = 0; if (!string.IsNullOrWhiteSpace(dto.Name) && !string.IsNullOrWhiteSpace(dto.Address.Street) && !string.IsNullOrWhiteSpace(dto.Address.Number) && !string.IsNullOrWhiteSpace(dto.Address.City) && !string.IsNullOrWhiteSpace(dto.Address.State) && dto.IsChecked) { infoStatus = 2; } else if (!string.IsNullOrWhiteSpace(dto.Name) && !string.IsNullOrWhiteSpace(dto.Address.Street) && !string.IsNullOrWhiteSpace(dto.Address.Number) && !string.IsNullOrWhiteSpace(dto.Address.City) && !string.IsNullOrWhiteSpace(dto.Address.State) && !dto.IsChecked) { infoStatus = 1; } return(new PartnerModel() { Id = dto.Id, Name = dto.Name, Email1 = dto.Email1, Email2 = dto.Email2, Tel1 = dto.Tel1, Tel2 = dto.Tel2, Cel1 = dto.Cel1, Cel2 = dto.Cel2, Url = dto.Url, FacebookUrl = dto.FacebookUrl, InstagramUrl = dto.InstagramUrl, IsChecked = dto.IsChecked, IsAuthorized = dto.IsAuthorized, ShowInApp = dto.ShowInApp, SubscriptionLevel = (int)dto.SubscriptionLevel, Accountable = dto.Accountable, Street = dto.Address?.Street ?? "", Number = dto.Address?.Number ?? "", PostalCode = dto.Address?.PostalCode ?? "", City = dto.Address?.City ?? "", Country = dto.Address?.Country ?? "", State = dto.Address?.State ?? "", Latitude = dto.Address?.Latitude ?? "", Longitude = dto.Address?.Longitude ?? "", Categories = dto.Categories?.Select(category => category.Id).ToList() ?? new List <string>(), Description = dto.Description, Notes = dto.Notes, InfoStatus = infoStatus, BusinessName = dto.CompanyData?.BusinessName ?? "", BusinessStreet = dto.CompanyData?.Address?.Street ?? "", BusinessNumber = dto.CompanyData?.Address?.Number ?? "", BusinessPostalCode = dto.CompanyData?.Address?.PostalCode ?? "", BusinessCity = dto.CompanyData?.Address?.City ?? "", BusinessCountry = dto.CompanyData?.Address?.Country ?? "", BusinessState = dto.CompanyData?.Address?.State ?? "", BusinessPec = dto.CompanyData?.Pec ?? "", BusinessTaxCode = dto.CompanyData?.TaxCode ?? "", BusinessVatNumber = dto.CompanyData?.VatNumber ?? "", BusinessTel = dto.CompanyData?.Tel ?? "", BusinessCel1 = dto.CompanyData?.Cel1 ?? "", BusinessCel2 = dto.CompanyData?.Cel2 ?? "", BusinessUniqueCode = dto.CompanyData?.UniqueCode ?? "", BusinessResponsibleName = dto.CompanyData?.Responsible?.Name ?? "", BusinessResponsibleSurname = dto.CompanyData?.Responsible?.Surname ?? "", BusinessResponsibleTel = dto.CompanyData?.Responsible?.Tel ?? "", BusinessResponsibleCel = dto.CompanyData?.Responsible?.Cel ?? "", ImageId = dto.Image?.Id, ContractId = dto.Documentation?.Contract?.Id ?? "", ConsensoId = dto.Documentation?.Consenso?.Id ?? "", PrivacyId = dto.Documentation?.Privacy?.Id ?? "", PagamentoId = dto.Documentation?.Pagamento?.Id ?? "", Openings = dto.Openings }); }
public DTOResponse <bool> Delete(DTOPartner deleteByIdInfo) { return(_domain.DeleteById(deleteByIdInfo.Id)); }
public DTOResponse <DTOPartner> Update(DTOPartner updateInfo) { return(_domain.Update(updateInfo)); }
public DTOResponse <DTOPartner> GetById(DTOPartner getByIdInfo) { return(_domain.GetById(getByIdInfo.Id)); }
public DTOResponse <DTOPartner> Create(DTOPartner createInfo) { return(_domain.Create(createInfo)); }
private void LoadPartnerData(DTOPartner dtoPartner, PartnerModel partnerModel) { if (partnerModel.Categories != null) { var getCategoriesResult = _partnerCategoryDomain.GetByIdList(partnerModel.Categories); if (getCategoriesResult.Code == 200) { dtoPartner.Categories = getCategoriesResult.Data; } } if (!string.IsNullOrWhiteSpace(partnerModel.ImageId)) { var getImageResult = _filesDomain.GetImageById(partnerModel.ImageId); if (getImageResult.Code == 200) { dtoPartner.Image = getImageResult.Data; } } var hasContractId = !string.IsNullOrWhiteSpace(partnerModel.ContractId); var hasConsensoId = !string.IsNullOrWhiteSpace(partnerModel.ConsensoId); var hasPrivacyId = !string.IsNullOrWhiteSpace(partnerModel.PrivacyId); var hasPagamentoId = !string.IsNullOrWhiteSpace(partnerModel.PagamentoId); if (hasContractId || hasConsensoId || hasPrivacyId || hasPagamentoId) { dtoPartner.Documentation = new DTOPartnerDocumentation(); if (hasContractId) { var getFileResult = _filesDomain.GetDocumentById(partnerModel.ContractId); if (getFileResult.Code == 200) { dtoPartner.Documentation.Contract = getFileResult.Data; } } if (hasConsensoId) { var getFileResult = _filesDomain.GetDocumentById(partnerModel.ConsensoId); if (getFileResult.Code == 200) { dtoPartner.Documentation.Consenso = getFileResult.Data; } } if (hasPrivacyId) { var getFileResult = _filesDomain.GetDocumentById(partnerModel.PrivacyId); if (getFileResult.Code == 200) { dtoPartner.Documentation.Privacy = getFileResult.Data; } } if (hasPagamentoId) { var getFileResult = _filesDomain.GetDocumentById(partnerModel.PagamentoId); if (getFileResult.Code == 200) { dtoPartner.Documentation.Pagamento = getFileResult.Data; } } } }
public DTOResponse <DTOPartner> Update(DTOPartner updateInfo) { var model = updateInfo.ToModel(); _collection.UpdateOne <PartnerModel>(model => model.Id == updateInfo.Id, Builders <PartnerModel> .Update .Set("Name", model.Name) .Set("Categories", model.Categories) .Set("Street", model.Street) .Set("Number", model.Number) .Set("PostalCode", model.PostalCode) .Set("City", model.City) .Set("Country", model.Country) .Set("State", model.State) .Set("Latitude", model.Latitude) .Set("Longitude", model.Longitude) .Set("Email1", model.Email1) .Set("Email2", model.Email2) .Set("Tel1", model.Tel1) .Set("Tel2", model.Tel2) .Set("Cel1", model.Cel1) .Set("Cel2", model.Cel2) .Set("Url", model.Url) .Set("FacebookUrl", model.FacebookUrl) .Set("InstagramUrl", model.InstagramUrl) .Set("IsChecked", model.IsChecked) .Set("IsAuthorized", model.IsAuthorized) .Set("ShowInApp", model.ShowInApp) .Set("SubscriptionLevel", model.SubscriptionLevel) .Set("Accountable", model.Accountable) .Set("Description", model.Description) .Set("Notes", model.Notes) .Set("InfoStatus", model.InfoStatus) .Set("BusinessName", model.BusinessName) .Set("BusinessStreet", model.BusinessStreet) .Set("BusinessNumber", model.BusinessNumber) .Set("BusinessPostalCode", model.BusinessPostalCode) .Set("BusinessCity", model.BusinessCity) .Set("BusinessCountry", model.BusinessCountry) .Set("BusinessState", model.BusinessState) .Set("BusinessPec", model.BusinessPec) .Set("BusinessTaxCode", model.BusinessTaxCode) .Set("BusinessVatNumber", model.BusinessVatNumber) .Set("BusinessTel", model.BusinessTel) .Set("BusinessCel1", model.BusinessCel1) .Set("BusinessCel2", model.BusinessCel2) .Set("BusinessPec", model.BusinessPec) .Set("BusinessUniqueCode", model.BusinessUniqueCode) .Set("BusinessResponsibleName", model.BusinessResponsibleName) .Set("BusinessResponsibleSurname", model.BusinessResponsibleSurname) .Set("BusinessResponsibleTel", model.BusinessResponsibleTel) .Set("BusinessResponsibleCel", model.BusinessResponsibleCel) .Set("ImageId", model.ImageId) .Set("ContractId", model.ContractId) .Set("ConsensoId", model.ConsensoId) .Set("PrivacyId", model.PrivacyId) .Set("PagamentoId", model.PagamentoId) .Set("Openings", model.Openings) ); return(new DTOResponse <DTOPartner>() { Code = 200 }); }