コード例 #1
0
ファイル: LeadRepository.cs プロジェクト: auditt98/VaniCRM
        public bool AddTag(int id, string tagName)
        {
            var dbLead = db.LEADs.Find(id);
            var dbTag  = _tagRepository.GetOneByName(tagName);

            if (dbLead != null)
            {
                if (dbTag != null)
                {
                    var tagItem = dbLead.TAG_ITEM.Where(c => c.TAG_ID == dbTag.ID).FirstOrDefault();
                    if (tagItem == null)
                    {
                        var newTagItem = new TAG_ITEM();
                        newTagItem.TAG_ID  = dbTag.ID;
                        newTagItem.LEAD_ID = dbLead.ID;
                        db.TAG_ITEM.Add(newTagItem);
                        db.SaveChanges();

                        var notifyModel = new NotificationApiModel();
                        notifyModel.title          = "Tag added to lead";
                        notifyModel.content        = $"Tag '{tagName}' has been added to lead {dbLead.Name}.";
                        notifyModel.module         = "leads";
                        notifyModel.moduleObjectId = dbLead.ID;
                        notifyModel.createdAt      = DateTime.Now;
                        NotificationManager.SendNotification(notifyModel, new List <USER> {
                            dbLead.Owner
                        });
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    var newTag  = _tagRepository.Create(tagName);
                    var tagItem = new TAG_ITEM();
                    tagItem.TAG_ID  = newTag.ID;
                    tagItem.LEAD_ID = dbLead.ID;
                    db.TAG_ITEM.Add(tagItem);
                    db.SaveChanges();

                    var notifyModel = new NotificationApiModel();
                    notifyModel.title          = "Tag added to lead";
                    notifyModel.content        = $"Tag '{tagName}' has been added to lead {dbLead.Name}.";
                    notifyModel.module         = "leads";
                    notifyModel.moduleObjectId = dbLead.ID;
                    notifyModel.createdAt      = DateTime.Now;
                    NotificationManager.SendNotification(notifyModel, new List <USER> {
                        dbLead.Owner
                    });
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public bool AddTag(int id, string tagName)
        {
            var dbContact = db.CONTACTs.Find(id);
            var dbTag     = _tagRepository.GetOneByName(tagName);

            if (dbContact != null)
            {
                if (dbTag != null)
                {
                    var tagItem = dbContact.TAG_ITEM.Where(c => c.TAG_ID == dbTag.ID).FirstOrDefault();
                    if (tagItem == null)
                    {
                        var newTagItem = new TAG_ITEM();
                        newTagItem.TAG_ID     = dbTag.ID;
                        newTagItem.CONTACT_ID = dbContact.ID;
                        db.TAG_ITEM.Add(newTagItem);
                        db.SaveChanges();

                        var owner        = db.USERs.Find(dbContact.ContactOwner);
                        var collaborator = db.USERs.Find(dbContact.ContactCollaborator);
                        var createdUser  = db.USERs.Find(dbContact.CreatedBy);

                        var notifyModel = new NotificationApiModel();
                        notifyModel.title          = "Tag added";
                        notifyModel.content        = $"Tag {tagName} has been added to contact {dbContact.Name}.";
                        notifyModel.module         = "contacts";
                        notifyModel.moduleObjectId = dbContact.ID;
                        notifyModel.createdAt      = DateTime.Now;
                        NotificationManager.SendNotification(notifyModel, new List <USER> {
                            owner, collaborator, createdUser
                        });
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    var newTag  = _tagRepository.Create(tagName);
                    var tagItem = new TAG_ITEM();
                    tagItem.TAG_ID     = newTag.ID;
                    tagItem.CONTACT_ID = dbContact.ID;
                    db.TAG_ITEM.Add(tagItem);
                    db.SaveChanges();
                    var owner        = db.USERs.Find(dbContact.ContactOwner);
                    var collaborator = db.USERs.Find(dbContact.ContactCollaborator);
                    var createdUser  = db.USERs.Find(dbContact.CreatedBy);
                    var notifyModel  = new NotificationApiModel();
                    notifyModel.title          = "Tag added";
                    notifyModel.content        = $"Tag {tagName} has been added to contact {dbContact.Name}.";
                    notifyModel.module         = "contacts";
                    notifyModel.moduleObjectId = dbContact.ID;
                    notifyModel.createdAt      = DateTime.Now;
                    NotificationManager.SendNotification(notifyModel, new List <USER> {
                        owner, collaborator, createdUser
                    });
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public bool AddTag(int id, string tagName)
        {
            var dbCampaign = db.CAMPAIGNs.Find(id);
            var dbTag      = _tagRepository.GetOneByName(tagName);

            if (dbCampaign != null)
            {
                if (dbTag != null)
                {
                    var tagItem = dbCampaign.TAG_ITEM.Where(c => c.TAG_ID == dbTag.ID).FirstOrDefault();
                    if (tagItem == null)
                    {
                        var newTagItem = new TAG_ITEM();
                        newTagItem.TAG_ID      = dbTag.ID;
                        newTagItem.CAMPAIGN_ID = dbCampaign.ID;
                        db.TAG_ITEM.Add(newTagItem);
                        db.SaveChanges();

                        var owner   = db.USERs.Find(dbCampaign.CampaignOwner);
                        var creator = db.USERs.Find(dbCampaign.CreatedBy);

                        var notifyModel = new NotificationApiModel();
                        notifyModel.title     = "Tag added";
                        notifyModel.content   = $"Tag  {tagName} has been added to campaign {dbCampaign.Name}.";
                        notifyModel.createdAt = DateTime.Now;
                        NotificationManager.SendNotification(notifyModel, new List <USER> {
                            owner, creator
                        });

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    var newTag  = _tagRepository.Create(tagName);
                    var tagItem = new TAG_ITEM();
                    tagItem.TAG_ID      = newTag.ID;
                    tagItem.CAMPAIGN_ID = dbCampaign.ID;
                    db.TAG_ITEM.Add(tagItem);
                    db.SaveChanges();

                    var owner   = db.USERs.Find(dbCampaign.CampaignOwner);
                    var creator = db.USERs.Find(dbCampaign.CreatedBy);

                    var notifyModel = new NotificationApiModel();
                    notifyModel.title     = "Tag added";
                    notifyModel.content   = $"Tag {tagName} has been added to campaign {dbCampaign.Name}.";
                    notifyModel.createdAt = DateTime.Now;
                    NotificationManager.SendNotification(notifyModel, new List <USER> {
                        owner, creator
                    });
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        public bool AddTag(int id, string tagName)
        {
            var dbDeal = db.DEALs.Find(id);
            var dbTag  = _tagRepository.GetOneByName(tagName);

            if (dbDeal != null)
            {
                if (dbTag != null)
                {
                    var tagItem = dbDeal.TAG_ITEM.Where(c => c.TAG_ID == dbTag.ID).FirstOrDefault();
                    if (tagItem == null)
                    {
                        var newTagItem = new TAG_ITEM();
                        newTagItem.TAG_ID  = dbTag.ID;
                        newTagItem.DEAL_ID = dbDeal.ID;
                        db.TAG_ITEM.Add(newTagItem);
                        db.SaveChanges();

                        var owner   = db.USERs.Find(dbDeal.DealOwner);
                        var creator = db.USERs.Find(dbDeal.CreatedBy);

                        var notifyModel = new NotificationApiModel();
                        notifyModel.title          = "Tag added";
                        notifyModel.content        = $"Tag {tagName} has been added to deal {dbDeal.Name}.";
                        notifyModel.module         = "deals";
                        notifyModel.moduleObjectId = dbDeal.ID;
                        notifyModel.createdAt      = DateTime.Now;
                        NotificationManager.SendNotification(notifyModel, new List <USER> {
                            owner, creator
                        });
                        NotificationManager.ReloadDashboardSale();

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    var newTag  = _tagRepository.Create(tagName);
                    var tagItem = new TAG_ITEM();
                    tagItem.TAG_ID  = newTag.ID;
                    tagItem.DEAL_ID = dbDeal.ID;
                    db.TAG_ITEM.Add(tagItem);
                    db.SaveChanges();
                    var owner   = db.USERs.Find(dbDeal.DealOwner);
                    var creator = db.USERs.Find(dbDeal.CreatedBy);

                    var notifyModel = new NotificationApiModel();
                    notifyModel.title          = "Tag added";
                    notifyModel.content        = $"Tag {tagName} has been added to deal {dbDeal.Name}.";
                    notifyModel.module         = "deals";
                    notifyModel.moduleObjectId = dbDeal.ID;
                    notifyModel.createdAt      = DateTime.Now;
                    NotificationManager.SendNotification(notifyModel, new List <USER> {
                        owner, creator
                    });
                    NotificationManager.ReloadDashboardSale();

                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }