Exemplo n.º 1
0
        public void AddToGroup(object sender, EventArgs e)
        {
            if (Request["contacts"] != null)
            {
                var items = Request["contacts"].ToString(); // Get the JSON string
                var group = Request["group"].ToString(); // Get the JSON string
                JArray groupdata = JArray.Parse(group); // It is an array so parse into a JArray
                JArray contactData = JArray.Parse(items);
                if (groupdata[0]["type"].ToString() == "old")
                {
                    for (int i = 0; i < contactData.Count(); i++)
                    {
                        var groupid = Int32.Parse(groupdata[0]["name"].ToString());
                        var conInfoId = Int32.Parse(contactData[i]["id"].ToString());
                        var find = AssTGSer.GetSingleAssignToGroup(groupid, conInfoId);
                        if (find == null)
                        {
                            AssignToGroup asshole = new AssignToGroup();
                            asshole.ContactGroupId = groupid;
                            asshole.ContactInfoId = conInfoId;
                            asshole.CreatedTime = DateTime.Now;
                            AssTGSer.CreateAssignToGroup(asshole);
                        }

                    }
                }
                else
                {
                    var tt = HttpContext.User.Identity.Name;
                    var user = uService.GetSingleUserByEmail(tt);
                    var logObj = _companyViewLog.GetLastViewCompanyByUserId(user.Id);
                    int companyId = 0;
                    if (logObj != null)
                    {
                        companyId = (int)logObj.CompanyId;
                    }
                    ContactGroup Group = new ContactGroup();
                    Group.GroupName = groupdata[0]["name"].ToString();
                    Group.CompanyId = companyId;
                    if (conGrpSer.CreateContactGroup(Group))
                    {
                        for (int i = 0; i < contactData.Count(); i++)
                        {
                            var groupid = Group.Id;
                            var conInfoId = Int32.Parse(contactData[i]["id"].ToString());
                            var find = AssTGSer.GetSingleAssignToGroup(groupid, conInfoId);
                            if (find == null)
                            {
                                AssignToGroup asshole = new AssignToGroup();
                                asshole.ContactGroupId = groupid;
                                asshole.ContactInfoId = conInfoId;
                                asshole.CreatedTime = DateTime.Now;
                                AssTGSer.CreateAssignToGroup(asshole);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public bool CreateContactGroup(ContactGroup contactGroup)
 {
     try
     {
         contactGroup.State = ObjectState.Added;
         _finalCrud.AddOperation(contactGroup);
         return true;
     }
     catch (Exception e)
     {
         var msg = e.Message;
         return false;
     }
 }
Exemplo n.º 3
0
        public ActionResult Create(string name)
        {
            var tt = HttpContext.User.Identity.Name;
            var user = uService.GetSingleUserByEmail(tt);
            var logObj = _companyViewLog.GetLastViewCompanyByUserId(user.Id);
            int companyId = 0;
            if (logObj != null)
            {
                companyId = (int)logObj.CompanyId;
            }
            ContactGroup Group = new ContactGroup();
            Group.GroupName = name;
            Group.CompanyId = companyId;

            if (conGSer.CreateContactGroup(Group))
            {
                return Json(new { msg = "Success" });
            }
            else
            {
                return Json(new { msg = "Failed" });
            }
        }