public void AddRemarksForEntry(Guid entryID,  Annotation data, string Username, string Password)
        {
            Entity note = new Entity("annotation");

            note["objectid"] = new EntityReference("gsc_timeentry", entryID);
            note["subject"] = data.Subject;
            note["notetext"] = data.NoteText;

            string Url = ConfigurationManager.AppSettings["Url"].ToString();
            string CrmConnectionString = string.Format("Url={0}; Username={1}; Password={2}",
                                                        Url, Username, Password);
            CrmConnection crmConnection = null;
            crmConnection = CrmConnection.Parse(CrmConnectionString);
            OrganizationService service = new OrganizationService(crmConnection);

            service.Create(note);
        }
 public ActionResult AddRemarks(Annotation data, string recordID)
 {
     /*
      * An ActionResult that process the post request for adding of remarks
      */
     if (Request.Cookies["UserSettings"] != null)
     {
         string username;
         string password;
         if (Request.Cookies["UserSettings"]["domain"] != null &&
             Request.Cookies["UserSettings"]["user"] != null)
         {
             username = Request.Cookies["UserSettings"]["domain"].Decrypt();
             password = Request.Cookies["UserSettings"]["user"].Decrypt();
             dbAnnotation.AddRemarksForEntry(new Guid(recordID), data, username, password);
         }
     }
     return RedirectToAction("Index", new { notify = true });
 }
        public IEnumerable<Annotation> GetNotesForEntry(string entityID)
        {
            SystemUserContext dbUser = new SystemUserContext();
            List<Annotation> remarks = new List<Annotation>();

            foreach (Entity entity in GetAttachments(new Guid(entityID)).Entities)
            {
                Annotation EntryRemarks = new Annotation();
                EntryRemarks.NoteText = entity["notetext"].ToString();
                EntryRemarks.Subject = entity["subject"].ToString();

                EntryRemarks.ManagerID = ((EntityReference)entity["createdby"]).Id;
                EntryRemarks.ManagerName = dbUser.GetFullNameForUser(EntryRemarks.ManagerID).Fullname;

                EntryRemarks.CreatedOn = Convert.ToDateTime(entity["createdon"]);
                remarks.Add(EntryRemarks);
            }

            return remarks;
        }