Esempio 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);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public bool CreateAssignToGroup(AssignToGroup assignToGroup)
 {
     try {
         assignToGroup.State = ObjectState.Added;
         _finalCrud.AddOperation(assignToGroup);
         return true;
     }catch(Exception ex){
         var msg = ex.Message;
         return false;
     }
 }