/// <summary>
        /// Sets the companyProfiles.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public CompanyProfileResponse SetCompanyProfiles(CompanyProfileRequest request)
        {
            var response = new CompanyProfileResponse();

            var companyProfileEntity = request.CompanyProfile;

            if (request.Action != PersistType.Delete)
            {
                if (!companyProfileEntity.Validate())
                {
                    foreach (var error in companyProfileEntity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
            }
            try
            {
                if (request.Action == PersistType.Insert)
                {
                    companyProfileEntity.LineId = CompanyProfileDao.InsertCompanyProfile(companyProfileEntity);
                    response.Message            = null;
                }
                else if (request.Action == PersistType.Update)
                {
                    response.Message = CompanyProfileDao.UpdateCompanyProfile(companyProfileEntity);
                }
                else
                {
                    var companyProfileForUpdate = CompanyProfileDao.GetCompanyProfile(request.CompanyProfileId);
                    response.Message = CompanyProfileDao.DeleteCompanyProfile(companyProfileForUpdate);
                }
            }
            catch (Exception ex)
            {
                response.Acknowledge = AcknowledgeType.Failure;
                response.Message     = ex.Message;
                return(response);
            }
            response.CompanyProfileId = companyProfileEntity != null ? 1 : 0;
            if (response.Message == null)
            {
                response.Acknowledge  = AcknowledgeType.Success;
                response.RowsAffected = 1;
            }
            else
            {
                response.Acknowledge  = AcknowledgeType.Failure;
                response.RowsAffected = 0;
            }

            return(response);
        }
        /// <summary>
        /// Gets the companyProfiles.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public CompanyProfileResponse GetCompanyProfiles(CompanyProfileRequest request)
        {
            var response = new CompanyProfileResponse();

            if (request.LoadOptions.Contains("CompanyProfiles"))
            {
                response.CompanyProfiles = request.LoadOptions.Contains("IsActive") ? CompanyProfileDao.GetCompanyProfilesByActive(true) : CompanyProfileDao.GetCompanyProfiles();
            }
            if (request.LoadOptions.Contains("CompanyProfile"))
            {
                response.CompanyProfile = CompanyProfileDao.GetCompanyProfile(request.CompanyProfileId);
            }

            return(response);
        }
Esempio n. 3
0
        public override Task <CompanyProfilePayload> ReadCompanyProfile(CompanyProfileRequest request, ServerCallContext context)
        {
            CompanyProfilePoco poco = _logic.Get(Guid.Parse(request.Id));

            return(new Task <CompanyProfilePayload>(
                       () => new CompanyProfilePayload()
            {
                Id = poco.Id.ToString(),
                RegistrationDate = Timestamp.FromDateTime((DateTime)poco.RegistrationDate),
                CompanyWebsite = poco.CompanyWebsite,
                ContactPhone = poco.ContactPhone,
                ContactName = poco.ContactName,
                CompanyLogo = Google.Protobuf.ByteString.CopyFrom(poco.CompanyLogo)
            }));
        }