public void Save(int workFlowUserAssignmentActionID)
        {
            using (var db = new CRMDb())
            {
                if (this.RoundRobinContactAssignmentID == 0)
                {
                    var assignment = GetObject();
                    assignment.WorkFlowUserAssignmentActionID = workFlowUserAssignmentActionID;

                    db.RoundRobinAssignment.Add(assignment);
                    db.SaveChanges();
                }
                else
                {
                    var assignment = GetObject();
                    if (workFlowUserAssignmentActionID != 0)
                    {
                        assignment.WorkFlowUserAssignmentActionID = workFlowUserAssignmentActionID;

                        db.Entry(assignment).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }
        }
Esempio n. 2
0
        public void UpdateLeadScoreRule(int accountId, int by)
        {
            using (CRMDb db = new CRMDb())
            {
                var rule = db.LeadScoreRules.Where(r => r.ConditionValue == this.WorkflowActionID.ToString()).FirstOrDefault();

                if (rule != null)
                {
                    var isActionDeleted = db.WorkflowActions.Where(a => a.WorkflowActionID == this.WorkflowActionID).Select(a => a.IsDeleted).FirstOrDefault();
                    if (isActionDeleted)
                    {
                        db.LeadScoreRules.Remove(rule);
                    }
                    else
                    {
                        rule.Score      = this.LeadScoreValue;
                        rule.ModifiedBy = by;
                        rule.ModifiedOn = DateTime.Now.ToUniversalTime();
                    }
                }
                else
                {
                    InsertLeadScoreRule(accountId, by, db);
                }
                db.SaveChanges();
            }
        }
Esempio n. 3
0
        public void Save(CRMDb db)
        {
            var index = 1;

            if (LinkActions != null)
            {
                LinkActions.Each(la =>
                {
                    index = 1;
                    if (la.Action != null)
                    {
                        if (la.WorkflowActionID == 0)
                        {
                            var wa = new WorkflowActionsDb()
                            {
                                OrderNumber          = index,
                                WorkflowActionTypeID = la.WorkflowActionTypeID,
                                IsSubAction          = true,
                                WorkflowID           = (short)WorkflowID
                            };
                            wa.Save(db);
                        }
                        else
                        {
                            la.OrderNumber = index;
                            la.IsSubAction = true;
                            la.WorkflowID  = (short)WorkflowID;
                            la.Save(db);
                        }
                        la.Action.Save(db);
                        db.SaveChanges();
                        if (!la.IsDeleted)
                        {
                            LinkActionID = la.Action.WorkflowActionID;
                            SaveActionLink(db);
                            db.SaveChanges();
                        }
                        index++;
                    }
                });
            }
        }