コード例 #1
0
        public List <tblCollaborator> Coll(tblCollaborator objtbl)
        {
            var Collaborator = new List <tblCollaborator>();

            ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());

            var data = from a in applicationDbContext.tblCollaborators
                       where a.SharID == user.Email && a.NotesID == objtbl.NotesID
                       select a;

            foreach (tblCollaborator col in data)
            {
                Collaborator.Add(col);
            }
            //if (Collaborator.Count() == 0)
            //{
            var data1 = from a in applicationDbContext.tblCollaborators
                        where a.OwnerID == user.Email && a.NotesID == objtbl.NotesID
                        select a;

            foreach (tblCollaborator col in data1)
            {
                Collaborator.Add(col);
            }
            //}
            return(Collaborator);
        }
コード例 #2
0
        public async Task <int> AddCollaboratorAsync(tblCollaborator objtbllabel)
        {
            int result = 0;

            result = await noteService.AddCollaborator(objtbllabel);

            return(result);
        }
コード例 #3
0
        public async Task <ActionResult> AddCollaborator(tblCollaborator objtbllabel)
        {
            if (objtbllabel.Mode == 1)
            {
                objtbllabel.OwnerID = Session["EmailId"].ToString();
            }

            int result = 0;

            result = await notesApicontroller.AddCollaboratorAsync(objtbllabel);

            return(View("GetNotes"));
        }
コード例 #4
0
        public async Task <string> Coll(tblCollaborator objtbl)
        {
            //Tuple<List<tblLabel>, List<tblLabelNotes>, List<tblCollaborator>> result = null;
            var list = new List <tblCollaborator>();

            list = noteService.Coll(objtbl);
            string JSONString;

            JSONString = JsonConvert.SerializeObject(list);

            return(JSONString);
            //return "";
        }
コード例 #5
0
        public async Task <int> AddCollaborator(tblCollaborator tblColl)
        {
            int result = 0;

            string ShareWth = string.Empty;

            ShareWth = tblColl.SharID;

            AccountService  accountService = new AccountService();
            ApplicationUser ShareWithdata  = await accountService.GetUser(ShareWth, 1);

            // if Email is not valid
            if (ShareWithdata == null)
            {
                //return result = "Email not register";
            }
            else
            {
                try
                {
                    if (tblColl.Mode == 1)
                    {
                        applicationDbContext.tblCollaborators.Add(tblColl);
                        result = await applicationDbContext.SaveChangesAsync();

                        return(result);
                    }
                    if (tblColl.Mode == 2)
                    {
                        //tblLabelNotes obj = applicationDbContext.tblLabelNotes.Where(i => i.LabelID == abc && i.NotesID == objtbl.ID).FirstOrDefault();
                        tblCollaborator obj = applicationDbContext.tblCollaborators.Where <tblCollaborator>(t => t.NotesID == tblColl.NotesID && t.OwnerID == tblColl.OwnerID && t.SharID == tblColl.SharID).First();
                        applicationDbContext.tblCollaborators.Remove(obj);
                        result = await applicationDbContext.SaveChangesAsync();

                        return(result);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(result);
        }
コード例 #6
0
        public async Task <string> OwnerLabel(tblNotes obj)
        {
            token = TempData["access_token"].ToString();
            TempData.Keep();

            int    result1 = 0;
            string re      = string.Empty;
            // Tuple<List<tblLabel>, List<tblLabelNotes>> result = null;
            string ABC = "";


            tblCollaborator objtbl = new tblCollaborator();
            string          userid = TempData["UserID"].ToString();

            objtbl.UserID  = userid;
            objtbl.NotesID = obj.ID;
            string myString = "";

            if (External != "Log")
            {
                ABC = await notesApicontroller.Coll(objtbl);

                myString = ABC;
            }
            else
            {
                ABC = await accountController.ConsumePostownerApi(objtbl, token);

                ABC      = ABC.Replace("\\", "");
                myString = ABC;

                myString = myString.Substring(0, myString.Length - 1);
                int index1 = myString.IndexOf('"');
                if (index1 != -1)
                {
                    myString = myString.Remove(index1, 1);
                }
            }


            return(myString);
        }
コード例 #7
0
        public async Task <string> ConsumePostownerApi(tblCollaborator model, string token)
        {
            try
            {
                var    client    = new HttpClient();
                string returnurl = currenturl + "/api/NotesApi/coll";

                client.BaseAddress = new Uri(returnurl);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);



                //var response = await client.GetAsync(returnurl);
                //var contents = await response.Content.ReadAsStringAsync();
                //var data = JsonConvert.DeserializeObject<List<tblLabelNotes>>(contents);

                var body = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("ID", Convert.ToString(model.ID)),
                    new KeyValuePair <string, string>("UserID", Convert.ToString(model.UserID)),
                    new KeyValuePair <string, string>("NotesID", Convert.ToString(model.NotesID)),
                    new KeyValuePair <string, string>("OwnerID", Convert.ToString(model.OwnerID)),
                    new KeyValuePair <string, string>("SharID", Convert.ToString(model.SharID)),
                };
                //var content = new FormUrlEncodedContent(body);
                var response = await client.PostAsync(returnurl, new FormUrlEncodedContent(body));

                // var response = await httpClient.PostAsync(returnurl, new FormUrlEncodedContent(body));

                var contents = await response.Content.ReadAsStringAsync();

                return(contents);
            }
            catch (Exception ex)
            {
                Logger.Write(ex.ToString());;
            }
            return("");
        }