public ContactStatusWrapper UpdateContactStatus(int id, string title, string description, string color, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

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

            var curListItemExist = DaoFactory.GetListItemDao().IsExist(id);
            if (!curListItemExist) throw new ItemNotFoundException();

            var listItem = new ListItem
                {
                    ID = id,
                    Title = title,
                    Description = description,
                    Color = color,
                    SortOrder = sortOrder
                };

            DaoFactory.GetListItemDao().EditItem(ListType.ContactStatus, listItem);
            MessageService.Send(_context, MessageAction.ContactTemperatureLevelUpdated, listItem.Title);

            return ToContactStatusWrapper(listItem);
        }
 public static void DemandEdit(ListItem listItem)
 {
     if (!CanEdit(listItem)) throw CreateSecurityException();
 }
        public virtual void EditItem(ListType listType, ListItem enumItem)
        {

            if (HaveRelativeItemsLink(listType, enumItem.ID))
                throw new ArgumentException();

            using (var db = GetDb())
            {
                db.ExecuteNonQuery(Update("crm_list_item")
                                         .Set("description", enumItem.Description)
                                         .Set("title", enumItem.Title)
                                         .Set("additional_params", enumItem.AdditionalParams)
                                         .Set("color", enumItem.Color)
                                         .Where(Exp.Eq("id", enumItem.ID)));
            }

            AdminLog.PostAction("CRM: saved crm category of type \"{0}\" with parameters {1:Json}", listType, enumItem);
        }
 public HistoryCategoryBaseWrapper(ListItem listItem)
     : base(listItem)
 {
     if (!String.IsNullOrEmpty(listItem.AdditionalParams))
         ImagePath = WebImageSupplier.GetAbsoluteWebPath(listItem.AdditionalParams, ProductEntryPoint.ID);
 }
Beispiel #5
0
        public virtual void EditItem(ListType listType, ListItem enumItem)
        {

            if (HaveRelativeItemsLink(listType, enumItem.ID))
                throw new ArgumentException();

            DbManager.ExecuteNonQuery(Update("crm_list_item")
                                      .Set("description", enumItem.Description)
                                      .Set("title", enumItem.Title)
                                      .Set("additional_params", enumItem.AdditionalParams)
                                      .Set("color", enumItem.Color)
                                      .Where(Exp.Eq("id", enumItem.ID)));


        }
 public TaskCategoryWrapper(ListItem listItem)
     : base(listItem)
 {
 }
 public ContactTypeWrapper(ListItem listItem)
     : base(listItem)
 {
 }
        public ContactTypeWrapper UpdateContactType(int id, string title, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

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

            var curListItemExist = DaoFactory.GetListItemDao().IsExist(id);
            if (!curListItemExist) throw new ItemNotFoundException();

            var listItem = new ListItem
                {
                    ID = id,
                    Title = title,
                    SortOrder = sortOrder
                };

            DaoFactory.GetListItemDao().EditItem(ListType.ContactType, listItem);
            MessageService.Send(Request, MessageAction.ContactTypeUpdated, listItem.Title);

            return ToContactTypeWrapper(listItem);
        }
        public HistoryCategoryWrapper CreateHistoryCategory(String title,
                                               String description,
                                               String imageName,
                                               int sortOrder)
        {

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

            var listItem = new ListItem
            {
                Title = title,
                Description = description,
                SortOrder = sortOrder,
                AdditionalParams = imageName
            };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.HistoryCategory, listItem);

            return ToHistoryCategoryWrapper(listItem);
        }
        public ContactStatusWrapper CreateContactStatus(string title, string description, string color, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            var listItem = new ListItem
                {
                    Title = title,
                    Description = description,
                    Color = color,
                    SortOrder = sortOrder
                };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.ContactStatus, listItem);
            MessageService.Send(Request, MessageAction.ContactTemperatureLevelCreated, listItem.Title);

            return ToContactStatusWrapper(listItem);
        }
        public ContactTypeWrapper CreateContactType(string title, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            var listItem = new ListItem
                {
                    Title = title,
                    Description = string.Empty,
                    SortOrder = sortOrder
                };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.ContactType, listItem);
            MessageService.Send(Request, MessageAction.ContactTypeCreated, listItem.Title);

            return ToContactTypeWrapper(listItem);
        }
        public TaskCategoryWrapper UpdateTaskCategory(int id, string title, string description, string imageName, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

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

            var curTaskCategoryExist = DaoFactory.GetListItemDao().IsExist(id);
            if (!curTaskCategoryExist) throw new ItemNotFoundException();

            var listItem = new ListItem
                {
                    Title = title,
                    Description = description,
                    SortOrder = sortOrder,
                    AdditionalParams = imageName,
                    ID = id
                };

            DaoFactory.GetListItemDao().EditItem(ListType.TaskCategory, listItem);
            MessageService.Send(Request, MessageAction.CrmTaskCategoryUpdated, listItem.Title);

            return ToTaskCategoryWrapper(listItem);
        }
        public TaskCategoryWrapper CreateTaskCategory(string title, string description, string imageName, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

            var listItem = new ListItem
                {
                    Title = title,
                    Description = description,
                    SortOrder = sortOrder,
                    AdditionalParams = imageName
                };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.TaskCategory, listItem);
            MessageService.Send(Request, MessageAction.CrmTaskCategoryCreated, listItem.Title);

            return ToTaskCategoryWrapper(listItem);
        }
Beispiel #14
0
        public virtual void EditItem(ListType listType, ListItem enumItem)
        {

            if (HaveRelativeItemsLink(listType, enumItem.ID))
            switch (listType)
            {
                case ListType.ContactStatus:
                case ListType.ContactType:
                    throw new ArgumentException(String.Format("{0}. {1}.", CRMErrorsResource.BasicCannotBeEdited, CRMErrorsResource.HasRelatedContacts));
                case ListType.TaskCategory:
                    throw new ArgumentException(String.Format("{0}. {1}.", CRMErrorsResource.BasicCannotBeEdited, CRMErrorsResource.TaskCategoryHasRelatedTasks));
                case ListType.HistoryCategory:
                    throw new ArgumentException(String.Format("{0}. {1}.", CRMErrorsResource.BasicCannotBeEdited, CRMErrorsResource.HistoryCategoryHasRelatedEvents));
                default:
                    throw new ArgumentException(String.Format("{0}.", CRMErrorsResource.BasicCannotBeEdited));
            }



            using (var db = GetDb())
            {
                db.ExecuteNonQuery(Update("crm_list_item")
                                         .Set("description", enumItem.Description)
                                         .Set("title", enumItem.Title)
                                         .Set("additional_params", enumItem.AdditionalParams)
                                         .Set("color", enumItem.Color)
                                         .Where(Exp.Eq("id", enumItem.ID)));
            }
        }
        public ContactType(ListItem listItem)
            : base(listItem)
        {

        }
        public HistoryCategoryWrapper UpdateHistoryCategory(
           int id, 
           String title,
           String description,
           String imageName,
           int sortOrder)
        {

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

            var listItem = new ListItem
            {
                Title = title,
                Description = description,
                SortOrder = sortOrder,
                AdditionalParams = imageName,
                ID = id
            };
            
            CRMSecurity.DemandEdit(listItem);

            DaoFactory.GetListItemDao().EditItem(ListType.HistoryCategory, listItem);

            return ToHistoryCategoryWrapper(listItem);
        }
 public TaskCategoryBaseWrapper(ListItem listItem)
     : base(listItem)
 {
     ImagePath = WebImageSupplier.GetAbsoluteWebPath(listItem.AdditionalParams, ProductEntryPoint.ID);
 }
        public TaskCategory CreateTaskCategory(String title,
                                               String description,
                                               String imageName,
                                               int sortOrder)
        {

            var listItem = new ListItem
            {
                Title = title,
                Description = description,
                SortOrder = sortOrder,
                AdditionalParams = imageName
            };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.TaskCategory, listItem);

            return ToTaskCategory(listItem);
        }
 public ContactStatusWrapper(ListItem listItem)
     : base(listItem)
 {
 }
        public TaskCategory UpdateTaskCategory(
           int id,
           String title,
           String description,
           String imageName,
           int sortOrder)
        {

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

            var curTaskCategory = DaoFactory.GetListItemDao().GetByID(id);

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

            var listItem = new ListItem
            {
                Title = title,
                Description = description,
                SortOrder = sortOrder,
                AdditionalParams = imageName,
                ID = id 
            };

            CRMSecurity.DemandEdit(listItem);


            DaoFactory.GetListItemDao().EditItem(ListType.TaskCategory, listItem);

            return ToTaskCategory(listItem);
        }
 protected ListItemWrapper(ListItem listItem)
     : base(listItem.ID)
 {
     Title = listItem.Title;
     Description = listItem.Description;
     Color = listItem.Color;
     SortOrder = listItem.SortOrder;
 }
        public ContactType UpdateContactType(
            int id, 
            String title,
            String description,
            String color,
            int sortOrder)
        {
            var listItem = new ListItem
            {
                Title = title,
                Description = description,
                Color = color,
                SortOrder = sortOrder
            };

            
            CRMSecurity.DemandEdit(listItem);

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.ContactStatus, listItem);

            return ToContactType(listItem);
        }
 public HistoryCategoryWrapper(ListItem listItem)
     : base(listItem)
 {
 }
        public ContactType ToContactType(ListItem listItem)
        {
            var result = new ContactType(listItem)
            {
                RelativeItemsCount = DaoFactory.GetListItemDao().GetRelativeItemsCount(ListType.ContactStatus, listItem.ID)

            };

            return result;
        }
Beispiel #25
0
 public static bool CanEdit(ListItem listItem)
 {
     return IsAdmin;
 }
        public HistoryCategoryWrapper ToHistoryCategoryWrapper(ListItem listItem)
        {
            var result = new HistoryCategoryWrapper(listItem)
            {
                                 RelativeItemsCount = DaoFactory.GetListItemDao().GetRelativeItemsCount(ListType.HistoryCategory,listItem.ID)

                             };

            return result;
        }
Beispiel #27
0
        public virtual int CreateItem(ListType listType, ListItem enumItem)
        {

            if (IsExist(listType, enumItem.Title))
                return GetByTitle(listType, enumItem.Title).ID;

            if (String.IsNullOrEmpty(enumItem.Title))
                throw new ArgumentException();

            if (listType == ListType.TaskCategory || listType == ListType.HistoryCategory)
                if (String.IsNullOrEmpty(enumItem.AdditionalParams))
                    throw new ArgumentException();
                else
                   enumItem.AdditionalParams = System.IO.Path.GetFileName(enumItem.AdditionalParams);
                
            if (listType == ListType.ContactStatus)
                if (String.IsNullOrEmpty(enumItem.Color))
                    throw new ArgumentException();

            var sortOrder = enumItem.SortOrder;

            using (var db = GetDb())
            {
                if (sortOrder == 0)
                    sortOrder = db.ExecuteScalar<int>(Query("crm_list_item")
                                                            .Where(Exp.Eq("list_type", (int)listType))
                                                            .SelectMax("sort_order")) + 1;

                AdminLog.PostAction("CRM: saved crm category of type \"{0}\" with parameters {1:Json}", listType, enumItem);

                return db.ExecuteScalar<int>(
                                                  Insert("crm_list_item")
                                                  .InColumnValue("id", 0)
                                                  .InColumnValue("list_type", (int)listType)
                                                  .InColumnValue("description", enumItem.Description)
                                                  .InColumnValue("title", enumItem.Title)
                                                  .InColumnValue("additional_params", enumItem.AdditionalParams)
                                                  .InColumnValue("color", enumItem.Color)
                                                  .InColumnValue("sort_order", sortOrder)
                                                  .Identity(1, 0, true));
            }
        }
        public TaskCategory ToTaskCategory(ListItem listItem)
        {

            var result = new TaskCategory(listItem)
                             {
                                 RelativeItemsCount = DaoFactory.GetListItemDao().GetRelativeItemsCount(ListType.TaskCategory,listItem.ID)

                             };

            return result;
        }
Beispiel #29
0
        public override void EditItem(ListType listType, ListItem enumItem)
        {
            ResetCache(enumItem.ID);

            base.EditItem(listType, enumItem);
        }
        public HistoryCategoryWrapper CreateHistoryCategory(string title, string description, string imageName, int sortOrder)
        {
            if (!(CRMSecurity.IsAdmin)) throw CRMSecurity.CreateSecurityException();

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

            var listItem = new ListItem
                {
                    Title = title,
                    Description = description,
                    SortOrder = sortOrder,
                    AdditionalParams = imageName
                };

            listItem.ID = DaoFactory.GetListItemDao().CreateItem(ListType.HistoryCategory, listItem);
            MessageService.Send(_context, MessageAction.HistoryEventCategoryCreated, listItem.Title);

            return ToHistoryCategoryWrapper(listItem);
        }