コード例 #1
0
ファイル: HomeController.cs プロジェクト: bjsn/WebApp
        public JsonResult AddOpportunityRow(OpportunityModel opportunity)
        {
            Mapper.CreateMap <OpportunityModel, OpportunityDto>()
            .ForMember(dest => dest.CloudLastUpdDT, opt => opt.Ignore())
            .ForMember(dest => dest.CloudLastUpdBy, opt => opt.Ignore())
            .ForMember(dest => dest.CloudLastUpdById, opt => opt.Ignore())
            .ForMember(dest => dest.OppStatus, opt => opt.MapFrom(src => src.OppStatusId))
            .ForMember(dest => dest.QuoteIDMainSite, opt => opt.Ignore())
            .ForMember(dest => dest.SDALastUpdBy, opt => opt.Ignore())
            .ForMember(dest => dest.SDALastUpdDT, opt => opt.Ignore())
            .ForMember(dest => dest.LoginInfo, opt => opt.Ignore())
            .ForMember(dest => dest.OpportunityTable, opt => opt.Ignore())
            .ForMember(dest => dest.CRMXrefDefinition, opt => opt.Ignore())
            .ForMember(dest => dest.CreateBy, opt => opt.Ignore())
            .ForMember(dest => dest.Quotes, opt => opt.Ignore());

            var opportunityDto = Mapper.Map <OpportunityModel, OpportunityDto>(opportunity);

            //Mapper.AssertConfigurationIsValid();

            opportunityDto.ClientID         = _authUser.ClientId;
            opportunityDto.CloudLastUpdById = _authUser.UserId;
            opportunityDto.CloudLastUpdDT   = DateTime.Today.ToString(CultureInfo.InvariantCulture);
            opportunityDto.SDALastUpdBy     = 0;
            opportunityDto.SDALastUpdDT     = DateTime.Today.ToString(CultureInfo.InvariantCulture);
            var nList     = _opportunityBl.AddOpportunity(opportunityDto);
            var userAdded = new UserHandlerModel();

            if (nList > 0)
            {
                var newOpp = _opportunityBl.GetNonDeletedOpportunityByClientIDAndOppID(_authUser.ClientId, nList);
                userAdded.MgUserId   = nList;
                userAdded.StrMessage = newOpp.CRMOppID;
            }
            else
            {
                userAdded.StrMessage = opportunityDto.ToString();
            }

            return(Json(userAdded, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
ファイル: UpdateCRMDataService.cs プロジェクト: bjsn/WebApp
        /// <summary>
        /// Get an opportunity by CRMOppID
        /// </summary>
        /// <param name="clientID">The ClientID</param>
        /// <param name="value">The value.</param>
        /// <param name="searchType">Type of the search.</param>
        /// <returns></returns>
        public Response GetOpportunityByClientIDAndSearchType(int clientID, string value, string searchType)
        {
            var            response      = new Response();
            var            opportunityBL = new OpportunityBL();
            OpportunityDto opportunity   = null;

            // Get the opportunity data
            switch (searchType.ToUpper())
            {
            case "CRMOPPID":
                opportunity = opportunityBL.GetNonDeletedOpportunityByClientIDAndCRMOppID(clientID, value);
                break;

            case "QUOTEID":
                opportunity = opportunityBL.GetNonDeletedOpportunityByClientIDAndQuoteID(clientID, value);
                break;

            case "OPPID":
                int oppId;
                if (int.TryParse(value, out oppId))
                {
                    opportunity = opportunityBL.GetNonDeletedOpportunityByClientIDAndOppID(clientID, oppId);
                }
                break;
            }

            if (opportunity != null)
            {
                response.Results.Add("Success");
                // Serialize the object
                string userSerialize = JsonConvert.SerializeObject(opportunity);
                response.Results.Add(userSerialize);
            }
            else
            {
                response.Results.Add("Error");
                response.Errors.Add("Invalid opportunity data.");
            }
            return(response);
        }