public int SaveOpportunity(Entity.Sales.Opportunity Model)
        {
            OpportunityDbModel DbModel = new OpportunityDbModel();

            Model.CopyPropertiesTo(DbModel);
            return(OpportunityDataAccess.SaveOpportunities(DbModel));
        }
 private void Save()
 {
     if (OpportunityControlValidation())
     {
         Business.Sales.Opportunity Obj   = new Business.Sales.Opportunity();
         Entity.Sales.Opportunity   Model = new Entity.Sales.Opportunity
         {
             Id                   = OpportunityId,
             CreatedBy            = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
             Description          = txtDescription.Text,
             Name                 = txtName.Text,
             SourceName           = txtSourceName.Text,
             ExpectedCloseDate    = txtExpectedCloseDate.Text == "" ? (DateTime?)null : Convert.ToDateTime(txtExpectedCloseDate.Text),
             BestPrice            = txtBestPrice.Text == "" ? (decimal?)null : Convert.ToDecimal(txtBestPrice.Text),
             LikelyPrice          = txtLikelyPrice.Text == "" ? (decimal?)null : Convert.ToDecimal(txtLikelyPrice.Text),
             WorstPrice           = txtWorstPrice.Text == "" ? (decimal?)null : Convert.ToDecimal(txtWorstPrice.Text),
             CampaignId           = ddlCampaign.SelectedValue == "0" ? (int?)null : Convert.ToInt32(ddlCampaign.SelectedValue),
             CommitStageId        = ddlCommitStage.SelectedValue == "0" ? (int?)null : Convert.ToInt32(ddlCommitStage.SelectedValue),
             LeadSource           = ddlLeadSource.SelectedValue == "0" ? (int?)null : Convert.ToInt32(ddlLeadSource.SelectedValue),
             IsActive             = true,
             ActivityLinkId       = ActivityLinkId,
             ChildActivityTypeId  = Convert.ToInt32(ActityType.Opportunity),
             SourceActivityTypeId = Convert.ToInt32(ActityType.Lead),
             SourceActivityId     = ddlLinkName.SelectedValue == "0" ? (int?)null : Convert.ToInt32(ddlLinkName.SelectedValue)
         };
         int rows = Obj.SaveOpportunity(Model);
         if (rows > 0)
         {
             ClearControls();
             LoadOpportunityList();
             OpportunityId     = 0;
             Message.IsSuccess = true;
             Message.Text      = "Saved Successfully";
         }
         else
         {
             Message.IsSuccess = false;
             Message.Text      = "Unable to save data.";
         }
         Message.Show = true;
     }
 }
 private void GetOpportunityById()
 {
     Business.Sales.Opportunity Obj         = new Business.Sales.Opportunity();
     Entity.Sales.Opportunity   Opportunity = Obj.GetOpportunityById(OpportunityId, Convert.ToInt32(ActityType.Lead), Convert.ToInt32(ActityType.Opportunity));
     if (Opportunity.Id != 0)
     {
         txtName.Text                 = Opportunity.Name;
         txtDescription.Text          = Opportunity.Description;
         txtExpectedCloseDate.Text    = Opportunity.ExpectedCloseDate == null ? string.Empty : Opportunity.ExpectedCloseDate.GetValueOrDefault().ToString("dd MMM yyyy");
         txtLikelyPrice.Text          = Opportunity.LikelyPrice == null ? string.Empty : Opportunity.LikelyPrice.ToString();
         txtBestPrice.Text            = Opportunity.BestPrice == null ? string.Empty : Opportunity.BestPrice.ToString();
         txtWorstPrice.Text           = Opportunity.WorstPrice == null ? string.Empty : Opportunity.WorstPrice.ToString();
         txtSourceName.Text           = Opportunity.SourceName;
         ddlCampaign.SelectedValue    = Opportunity.CampaignId == null ? "0" : Opportunity.CampaignId.ToString();
         ddlCommitStage.SelectedValue = Opportunity.CommitStageId == null ? "0" : Opportunity.CommitStageId.ToString();
         ddlLeadSource.SelectedValue  = Opportunity.LeadSource == null ? "0" : Opportunity.LeadSource.ToString();
         ddlLinkName.SelectedValue    = Opportunity.SourceActivityId == null ? "0" : Opportunity.SourceActivityId.ToString();
         ActivityLinkId               = Opportunity.ActivityLinkId;
     }
 }
 public Entity.Sales.Opportunity GetOpportunityById(int Id, int SourceTypeId, int ChildTypeId)
 {
     Entity.Sales.Opportunity Opportunity = new Entity.Sales.Opportunity();
     OpportunityDataAccess.GetOpportunityById(Id, SourceTypeId, ChildTypeId).CopyPropertiesTo(Opportunity);
     return(Opportunity);
 }