public string AddContactsToGroups(ContactsSummary ouser) { try { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(@"http://" + GeneralBLL.Service_Link + "/Services/ContactsService.svc/AddGroupContacts"); httpWebRequest.Method = "POST"; httpWebRequest.ContentType = @"application/json; charset=utf-8"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = new JavaScriptSerializer().Serialize(ouser); streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); return(result.Replace("\"", "")); } } catch (Exception ex) { return(string.Empty); } }
public ActionResult AddGroupContact(ContactsSummary obj) { ContactsBLL ocntsBLL = new ContactsBLL(); EventsBLL oeventsBLL = new EventsBLL(); List <GoogleContacts> odetails = new List <GoogleContacts>(); foreach (var item in obj.UserContacts) { if (item.Selected == true) { odetails.Add(new GoogleContacts( item.EmailID, item.UserId, item.Selected, item.GroupId )); } } obj.UserContacts = odetails.ToArray(); obj.createrId = Session["UserId"].ToString(); var status = ocntsBLL.AddContactsToGroups(obj); if (status == "1") { return(Content("Contact Added Successfully", "text/html")); } else { return(Content("Contact Adding Failed", "text/html")); } }
public string AddGroupContacts(ContactsSummary obj) { try { U_USR_Map_Usr_To_ContactDAL ocontactsDAL = new U_USR_Map_Usr_To_ContactDAL(); U_USR_Map_Usr_To_Contact ocnts = new U_USR_Map_Usr_To_Contact(); foreach (var items in obj.UserContacts) { if (string.IsNullOrEmpty(ocontactsDAL.IsGroupContact_Exist(obj.groupId, items.UserId))) { ocnts.UsrMap_Seq_Id = Guid.NewGuid().ToString(); ocnts.Usr_Id = obj.createrId; ocnts.Contact_Id = items.UserId; ocnts.Group_Id = obj.groupId; ocnts.Comments = ""; ocnts.Created_by = ""; ocnts.Created_Date = DateTime.Now; ocnts.Updated_by = ""; ocnts.Updated_Date = DateTime.Now; ocontactsDAL.InsertU_USR_Map_Usr_To_Contact(ocnts); } } return("1"); // 1 successfull } catch (Exception ex) { Console.Write(ex); return("0"); // 0 indicates unsuccessfull } }
public ActionResult P_AddContact(string Group_Id) { ContactsBLL ocntsBLL = new ContactsBLL(); var obj = ocntsBLL.GetUserContacts(Session["UserId"].ToString()); ContactsSummary osummary = new ContactsSummary(); osummary.UserContacts = obj; osummary.groupId = Group_Id; return(PartialView("_AddGroupContacts", osummary));; }
public ViewResult Summary() { ContactsSummary summary = new ContactsSummary(); summary.NumberOfContacts = db.Contacts.Count(); summary.TotalOfComputers = db.Contacts.AsEnumerable().Sum(t => t.NumberOfComputers); ViewBag.Summary = summary; IQueryable <AddressesPerContact> data = from address in db.Addresses join contacts in db.Contacts on address.ContactID equals contacts.ID group new { contacts.FirstName, contacts.LastName, address.ContactID } by address.ContactID into addressGroup select new AddressesPerContact { FirstName = addressGroup.Select(f => f.FirstName).FirstOrDefault().ToString(), LastName = addressGroup.Select(f => f.LastName).FirstOrDefault().ToString(), NumberOfAddresses = addressGroup.Count() }; return(View(data.ToList())); }