Ejemplo n.º 1
0
        public DealMilestoneWrapper CreateDealMilestone(
            String title,
            String description,
            String color,
            int successProbability,
            DealMilestoneStatus stageType)
        {

            if (String.IsNullOrEmpty(title))
                throw new ArgumentException();

            if (successProbability < 0)
                successProbability = 0;

            var dealMilestone = new DealMilestone
                                    {
                                        Title = title,
                                        Color = color,
                                        Description = description,
                                        Probability = successProbability,
                                        Status = stageType
                                    };

            dealMilestone.ID = DaoFactory.GetDealMilestoneDao().Create(dealMilestone);

            return ToDealMilestoneWrapper(dealMilestone);

        }
Ejemplo n.º 2
0
        public DealMilestoneWrapper CreateDealMilestone(
            string title,
            string description,
            string color,
            int successProbability,
            DealMilestoneStatus stageType)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            if (string.IsNullOrEmpty(title)) throw new ArgumentException();

            if (successProbability < 0) successProbability = 0;

            var dealMilestone = new DealMilestone
                {
                    Title = title,
                    Color = color,
                    Description = description,
                    Probability = successProbability,
                    Status = stageType
                };

            dealMilestone.ID = DaoFactory.GetDealMilestoneDao().Create(dealMilestone);
            MessageService.Send(Request, MessageAction.OpportunityStageCreated, dealMilestone.Title);

            return ToDealMilestoneWrapper(dealMilestone);
        }
Ejemplo n.º 3
0
        public override int Create(DealMilestone item)
        {
            item.ID = base.Create(item);

            _dealMilestoneCache.Add(item.ID.ToString(), item);

            return item.ID;
        }
Ejemplo n.º 4
0
        public DealMilestoneWrapper(DealMilestone dealMilestone)
            : base(dealMilestone.ID)
        {

            SuccessProbability = dealMilestone.Probability;
            StageType = dealMilestone.Status;
            Color = dealMilestone.Color;
            Description = dealMilestone.Description;
            Title = dealMilestone.Title;
        }
Ejemplo n.º 5
0
 public DealMilestoneWrapper(DealMilestone dealMilestone)
     : base(dealMilestone)
 {
 }
Ejemplo n.º 6
0
        public override void Edit(DealMilestone item)
        {
            ResetCache(item.ID);

            base.Edit(item);
        }
Ejemplo n.º 7
0
        public virtual void Edit(DealMilestone item)
        {

            if (HaveContactLink(item.ID))
                throw new ArgumentException();

            using (var db = GetDb())
            {
                db.ExecuteNonQuery(Update("crm_deal_milestone")
                                        .Set("title", item.Title)
                                        .Set("description", item.Description)
                                        .Set("color", item.Color)
                                        .Set("probability", item.Probability)
                                        .Set("status", (int)item.Status)
                                        .Where(Exp.Eq("id", item.ID)));
            }

            AdminLog.PostAction("CRM: saved opportunity stage {0:Json}", item);
        }
Ejemplo n.º 8
0
        public virtual int Create(DealMilestone item)
        {

            if (String.IsNullOrEmpty(item.Title) || String.IsNullOrEmpty(item.Color))
                throw new ArgumentException();

            int id;

            using (var db = GetDb())
            using (var tx = db.BeginTransaction())
            {
                if (item.SortOrder == 0)
                    item.SortOrder = db.ExecuteScalar<int>(Query("crm_deal_milestone")
                                                            .SelectMax("sort_order")) + 1;

                id = db.ExecuteScalar<int>(
                                  Insert("crm_deal_milestone")
                                 .InColumnValue("id", 0)
                                 .InColumnValue("title", item.Title)
                                 .InColumnValue("description", item.Description)
                                 .InColumnValue("color", item.Color)
                                 .InColumnValue("probability", item.Probability)
                                 .InColumnValue("status", (int)item.Status)
                                 .InColumnValue("sort_order", item.SortOrder)
                                 .Identity(1, 0, true));
                tx.Commit();
            }

            AdminLog.PostAction("CRM: saved opportunity stage {0}", item);

            return id;

        }
Ejemplo n.º 9
0
        public virtual void Edit(DealMilestone item)
        {

            if (HaveContactLink(item.ID))
                throw new ArgumentException();

            DbManager.ExecuteNonQuery(Update("crm_deal_milestone")
                                     .Set("title", item.Title)
                                     .Set("description", item.Description)
                                     .Set("color", item.Color)
                                     .Set("probability", item.Probability)
                                     .Set("status", (int)item.Status)
                                     .Where(Exp.Eq("id", item.ID)));
        }
Ejemplo n.º 10
0
        public DealMilestoneWrapper UpdateDealMilestone(
            int id,
            String title,
            String description,
            String color,
            int successProbability,
            DealMilestoneStatus stageType)
        {

            if (id <= 0)
                throw new ArgumentException();

            if (successProbability < 0)
                successProbability = 0;

            var curDealMilestone = DaoFactory.GetDealMilestoneDao().GetByID(id);

            if (curDealMilestone == null)
                throw new ItemNotFoundException();

            var dealMilestone = new DealMilestone
            {
                Title = title,
                Color = color,
                Description = description,
                Probability = successProbability,
                Status = stageType,
                ID = id
            };

            DaoFactory.GetDealMilestoneDao().Edit(dealMilestone);

            return ToDealMilestoneWrapper(dealMilestone);

        }
Ejemplo n.º 11
0
        private DealMilestoneWrapper ToDealMilestoneWrapper(DealMilestone dealMilestone)
        {
            var result = new DealMilestoneWrapper(dealMilestone)
                             {
                                 RelativeItemsCount = DaoFactory.GetDealMilestoneDao().GetRelativeItemsCount(dealMilestone.ID)
                             };

            return result;
        }
Ejemplo n.º 12
0
        public DealMilestoneWrapper UpdateDealMilestone(
            int id,
            string title,
            string description,
            string color,
            int successProbability,
            DealMilestoneStatus stageType)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            if (id <= 0 || string.IsNullOrEmpty(title)) throw new ArgumentException();

            if (successProbability < 0) successProbability = 0;

            var curDealMilestoneExist = DaoFactory.GetDealMilestoneDao().IsExist(id);
            if (!curDealMilestoneExist) throw new ItemNotFoundException();

            var dealMilestone = new DealMilestone
                {
                    Title = title,
                    Color = color,
                    Description = description,
                    Probability = successProbability,
                    Status = stageType,
                    ID = id
                };

            DaoFactory.GetDealMilestoneDao().Edit(dealMilestone);
            MessageService.Send(Request, MessageAction.OpportunityStageUpdated, dealMilestone.Title);

            return ToDealMilestoneWrapper(dealMilestone);
        }
Ejemplo n.º 13
0
        public virtual void Edit(DealMilestone item)
        {

            if (HaveContactLink(item.ID))
                throw new ArgumentException(String.Format("{0}. {1}.", CRMErrorsResource.BasicCannotBeEdited, CRMErrorsResource.DealMilestoneHasRelatedDeals));

            using (var db = GetDb())
            {
                db.ExecuteNonQuery(Update("crm_deal_milestone")
                                        .Set("title", item.Title)
                                        .Set("description", item.Description)
                                        .Set("color", item.Color)
                                        .Set("probability", item.Probability)
                                        .Set("status", (int)item.Status)
                                        .Where(Exp.Eq("id", item.ID)));
            }
        }