Exemple #1
0
        public async Task <ActionResult> addnotelabel(tblNotes objtbl)
        {
            token = TempData["access_token"].ToString();
            TempData.Keep();
            objtbl.UserID = UserId;
            int    result = 0;
            string re     = string.Empty;

            if (External != "Log")
            {
                result = await notesApicontroller.addnotelabel(objtbl);
            }
            else
            {
                result = await accountController.ConsumePostLabelApi(objtbl, token);
            }


            //string userid = TempData["UserID"].ToString();
            //int i = 0;
            //if (ModelState.IsValid)
            //{
            //    i = await notesApicontroller.addnotelabel(objtbl);
            //}
            //  labelshow();

            TempData["UserID"] = UserId;
            TempData.Keep();
            return(View("GetNotes"));
        }
Exemple #2
0
        public List <tblNotes> Displaylabel(object label, object userId)
        {
            var listlabels = new List <int>();
            var list       = new List <tblNotes>();

            tblNotes tblNote  = new tblNotes();
            string   lablestr = "";
            var      iddata   = from a in applicationDbContext.tblLabels
                                where a.Label == label.ToString()
                                select a;

            foreach (tblLabel itemdata in iddata)
            {
                lablestr = itemdata.ID.ToString();
            }

            var Notesdata = (from t in applicationDbContext.tblNotes
                             join tb in applicationDbContext.tblLabelNotes on t.ID equals tb.NotesID

                             where t.UserID == userId && tb.LabelID == lablestr
                             select t).ToList();

            // Select All rows from tblnotes.
            foreach (tblNotes data in Notesdata)
            {
                list.Add(data);
            }
            return(list);
        }
Exemple #3
0
        public async Task <ActionResult> GetNotes(tblNotes objtbl)
        {
            token = TempData["access_token"].ToString();
            TempData.Keep();
            objtbl.UserID = UserId;
            int    result = 0;
            string re     = string.Empty;

            //if (ModelState.IsValid)
            //{
            //    i = await notesApicontroller.AddNotes(objtbl);
            //}


            if (ModelState.IsValid)
            {
                if (External != "Log")
                {
                    result = await notesApicontroller.AddNotes(objtbl);
                }
                else
                {
                    result = await accountController.ConsumePostApi(objtbl, token);
                }


                return(View());
            }
            return(View());
        }
        public async Task <string> UploadImage()
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new System.Web.Http.HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }
            string fileSaveLocation = HttpContext.Current.Server.MapPath("~/Images");

            CustomMultipartFormDataStreamProvider provider = new CustomMultipartFormDataStreamProvider(fileSaveLocation);
            List <string> files = new List <string>();

            await Request.Content.ReadAsMultipartAsync(provider);

            var data = provider.FileData.Count;

            var      Title     = provider.FormData["Title"];
            var      Content   = provider.FormData["Content"];
            var      ColorCode = provider.FormData["ColorCode"];
            var      ID        = provider.FormData["ID"];
            var      IsPin     = provider.FormData["IsPin"];
            string   Reminder  = provider.FormData["Reminder"];
            var      IsArchive = provider.FormData["IsArchive"];
            var      IsTrash   = provider.FormData["IsTrash"];
            var      owner     = provider.FormData["owner"];
            var      Label     = provider.FormData["Label"];
            var      share     = provider.FormData["share"];
            var      UserID    = provider.FormData["UserID"];
            tblNotes model     = new tblNotes();
            var      url       = RequestContext.Url.Request.RequestUri.Authority;

            foreach (MultipartFileData file in provider.FileData)
            {
                files.Add(Path.GetFileName(file.LocalFileName));

                var fileLocation = file.LocalFileName;
                var split        = fileLocation.Split('\\');
                var length       = split.Length;
                var filename     = split[length - 1];

                model.Title     = Title;
                model.Content   = Content;
                model.ColorCode = ColorCode;
                model.ImageUrl  = "https://" + url + "/Images/" + filename;
                model.ID        = Convert.ToInt16(ID);
                model.Mode      = 3;
                model.Reminder  = Reminder;
                model.IsPin     = Convert.ToInt16(IsPin);
                model.IsTrash   = Convert.ToInt16(IsTrash);
                model.Label     = Label;
                model.owner     = owner;
                model.share     = share;
                model.UserID    = UserID;
            }

            NotesController notesController = new NotesController();
            await noteService.AddNotes(model);

            return(model.ImageUrl);
        }
Exemple #5
0
        public async Task <ActionResult> UpdateColor(tblNotes model)
        {
            int i = 0;

            i = await notesApicontroller.UpdateColor(model);

            return(View("GetNotes"));
        }
        public async Task <int> addnotelabel(tblNotes objtbl)
        {
            int result = 0;

            result = await noteService.addnotelabel(objtbl);

            return(result);
        }
Exemple #7
0
        public async Task <ActionResult> UpdatePin(tblNotes model)
        {
            int i = 0;

            if (ModelState.IsValid)
            {
                i = await notesApicontroller.UpdatePin(model);
            }
            return(View("GetNotes"));
        }
        public async Task <int> UpdateColor(tblNotes model)
        {
            int i = 0;

            if (ModelState.IsValid)
            {
                i = await noteService.UpdateColor(model);
            }
            return(i);
        }
        public async Task <int> AddNotes(tblNotes model)
        {
            int i = 0;

            if (ModelState.IsValid)
            {
                i = await noteService.AddNotes(model);
            }
            return(i);
        }
        public async Task <int> AddNotes(tblNotes objtbl)
        {
            int result = 0;

            try
            {
                if (objtbl.Mode == 1)
                {
                    applicationDbContext.tblNotes.Add(objtbl);
                    result = await applicationDbContext.SaveChangesAsync();

                    return(result);
                }
                //Delete Note Forever.
                if (objtbl.Mode == 2)
                {
                    tblNotes obj = applicationDbContext.tblNotes.Where <tblNotes>(t => t.ID == objtbl.ID).First();
                    applicationDbContext.tblNotes.Remove(obj);
                    result = await applicationDbContext.SaveChangesAsync();

                    return(result);
                }

                // Update Note:Pinned note,delete note.
                if (objtbl.Mode == 3)
                {
                    tblNotes obj = applicationDbContext.tblNotes.Where <tblNotes>(t => t.ID == objtbl.ID).First();
                    obj.Title     = objtbl.Title;
                    obj.ID        = objtbl.ID;
                    obj.UserID    = objtbl.UserID;
                    obj.Content   = objtbl.Content;
                    obj.ColorCode = objtbl.ColorCode;
                    obj.IsPin     = objtbl.IsPin;
                    obj.IsTrash   = objtbl.IsTrash;
                    obj.IsArchive = objtbl.IsArchive;
                    obj.ID        = objtbl.ID;
                    obj.Reminder  = objtbl.Reminder;
                    obj.ImageUrl  = objtbl.ImageUrl;

                    result = await applicationDbContext.SaveChangesAsync();

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


            return(result);
        }
Exemple #11
0
        //public string labelshow()
        //{
        //    tblLabelNotes objtbl = new tblLabelNotes();
        //    string userid=TempData["UserID"].ToString();
        //    Tuple<List<tblLabel>, List<tblLabelNotes>> result=null;
        //    //int result = 0;
        //    if (ModelState.IsValid)
        //    {
        //        result = notesApicontroller.labelshow(objtbl, userid);
        //    }
        //    string JSONString;
        //    JSONString = JsonConvert.SerializeObject(result);

        //    return JSONString;
        //}
        public async Task <string> labelshow()
        {
            token = TempData["access_token"].ToString();
            TempData.Keep();
            tblNotes obj = new tblNotes();

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


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

            objtbl.UserID = userid;
            string myString;

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

                myString = ABC;
            }
            else
            {
                ABC = await accountController.ConsumePostchipApi(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);
                }
            }

            // Tuple<List<tblLabel>, List<tblLabelNotes>> result=null;
            //int result = 0;
            //if (ModelState.IsValid)
            //{
            //    result = notesApicontroller.labelshow(objtbl, userid);
            //}
            //string JSONString;
            // JSONString = JsonConvert.SerializeObject(ABC);

            return(myString);
        }
Exemple #12
0
        public async Task <int> ConsumePostLabelApi(tblNotes model, string token)
        {
            try
            {
                var    client    = new HttpClient();
                string returnurl = currenturl + "/api/NotesApi/addnotelabel";

                client.BaseAddress = new Uri(returnurl);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                var body = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("ID", Convert.ToString(model.ID)),
                    new KeyValuePair <string, string>("Content", model.Content),
                    new KeyValuePair <string, string>("UserID", Convert.ToString(model.UserID)),
                    new KeyValuePair <string, string>("Title", model.Title),
                    new KeyValuePair <string, string>("Mode", Convert.ToString(model.Mode)),
                    new KeyValuePair <string, string>("IsPin", Convert.ToString(model.IsPin)),
                    new KeyValuePair <string, string>("ColorCode", (model.ColorCode)),
                    new KeyValuePair <string, string>("Reminder", (model.Reminder)),
                    new KeyValuePair <string, string>("IsArchive", Convert.ToString(model.IsArchive)),
                    new KeyValuePair <string, string>("IsActive", Convert.ToString(model.IsActive)),
                    new KeyValuePair <string, string>("IsDelete", Convert.ToString(model.IsDelete)),
                    new KeyValuePair <string, string>("IsTrash", Convert.ToString(model.IsTrash)),
                    new KeyValuePair <string, string>("ImageUrl", model.ImageUrl),
                    new KeyValuePair <string, string>("Label", model.Label),
                    new KeyValuePair <string, string>("owner", model.owner),
                    new KeyValuePair <string, string>("Share", model.share)
                };
                var content = new FormUrlEncodedContent(body);
                //      HttpResponseMessage response = await client.PostAsync(returnurl, content);

                //

                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;

                return(1);
            }
            catch (Exception ex)
            {
                Logger.Write(ex.ToString());;
            }
            return(0);
        }
Exemple #13
0
        public int PutNotes(tblNotes model)
        {
            int result = 0;

            try
            {
                _context.tblNotes.Add(model);
                result = _context.SaveChanges();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(result);
        }
        public async Task <int> UpdateColor(tblNotes model)
        {
            int i = 0;

            try
            {
                tblNotes tbl = applicationDbContext.tblNotes.Where <tblNotes>(a => a.ID == model.ID).First();
                tbl.ColorCode = model.ColorCode;
                i             = await applicationDbContext.SaveChangesAsync();

                return(i);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(i);
        }
Exemple #15
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);
        }
        public int UpdateNote([FromBody] tblNotes note)
        {
            int result = 0;

            try
            {
                //var id = from a in _context.tblNotes
                //         where a.Id == note.Id
                //         select a;
                tblNotes notes = _context.tblNotes.Where <tblNotes>(a => a.Id == note.Id).First();
                notes.isPin     = note.isPin;
                notes.isArchive = note.isArchive;
                notes.isTrash   = note.isTrash;
                result          = _context.SaveChanges();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(result);
        }
        public async Task <int> UpdatePin(tblNotes model)
        {
            int i = 0;

            try
            {
                tblNotes tbl = applicationDbContext.tblNotes.Where <tblNotes>(a => a.ID == model.ID).First();
                if (model.IsPin == 1)
                {
                    tbl.IsPin = 0;
                }
                else
                {
                    tbl.IsPin = 1;
                }
                i = i = await applicationDbContext.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(i);
        }
Exemple #18
0
        public List <tblNotes> GetNotes(string Userid)
        {
            var      list      = new List <tblNotes>();
            var      sharelist = new List <tblCollaborator>();
            tblNotes tblNote   = new tblNotes();

            var             Notesdata = from t in applicationDbContext.tblNotes where t.UserID == Userid select t;
            ApplicationUser user      = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());

            var newdata = from t in applicationDbContext.tblCollaborators
                          where t.SharID == user.Email
                          select t;

            foreach (tblCollaborator data in newdata)
            {
                sharelist.Add(data);
            }
            for (int i = 0; i < sharelist.Count(); i++)
            {
                int id        = sharelist[i].NotesID;
                var sharedata = from t in applicationDbContext.tblNotes
                                where t.ID == id
                                select t;
                foreach (tblNotes data in sharedata)
                {
                    list.Add(data);
                }
            }

            // Select All rows from tblnotes.
            foreach (tblNotes data in Notesdata)
            {
                list.Add(data);
            }
            return(list);
        }
Exemple #19
0
        public async Task <int> addnotelabel(tblNotes objtbl)
        {
            int result = 0;
            // Add new label.
            var listlabels = new List <int>();
            var labelnames = new List <string>();

            if (objtbl.Mode == 1)
            {
                try
                {
                    var labels = objtbl.Label.Split(',');

                    foreach (string data in labels)
                    {
                        labelnames.Add(data);
                    }

                    foreach (string item in labelnames)
                    {
                        var iddata = from a in applicationDbContext.tblLabels
                                     where a.Label == item
                                     select a;
                        foreach (tblLabel itemdata in iddata)
                        {
                            listlabels.Add(itemdata.ID);
                        }
                    }

                    for (int i = 0; i < listlabels.Count(); i++)
                    {
                        string cn    = listlabels[i].ToString();
                        var    check = from a in applicationDbContext.tblLabelNotes
                                       where a.NotesID == objtbl.ID && a.LabelID == cn
                                       select a;

                        if (check.Count() == 0)
                        {
                            tblLabelNotes label = new tblLabelNotes();

                            label.LabelID = cn;
                            label.NotesID = objtbl.ID;
                            label.UserID  = objtbl.UserID;
                            applicationDbContext.tblLabelNotes.Add(label);
                            result = await applicationDbContext.SaveChangesAsync();
                        }
                    }
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }

                return(result);
            }

            if (objtbl.Mode == 2)
            {
                var iddata = from a in applicationDbContext.tblLabels
                             where a.Label == objtbl.Label
                             select a;
                foreach (tblLabel itemdata in iddata)
                {
                    listlabels.Add(itemdata.ID);
                }

                var           abc = listlabels[0].ToString();
                tblLabelNotes obj = applicationDbContext.tblLabelNotes.Where(i => i.LabelID == abc && i.NotesID == objtbl.ID).FirstOrDefault();
                applicationDbContext.tblLabelNotes.Remove(obj);

                result = await applicationDbContext.SaveChangesAsync();
            }

            if (objtbl.Mode == 3)
            {
                try
                {
                    var latestid = from a in applicationDbContext.tblNotes
                                   orderby a.ID descending
                                   select a.ID;
                    var id = latestid.First();

                    var newrecord = from a in applicationDbContext.tblLabelNotes
                                    where a.UserID == objtbl.UserID && a.NotesID == objtbl.ID
                                    select a;
                    var list = new List <string>();
                    foreach (tblLabelNotes tbl in newrecord)
                    {
                        list.Add(tbl.LabelID);
                    }

                    for (int i = 0; i < list.Count(); i++)
                    {
                        tblLabelNotes label = new tblLabelNotes();

                        label.LabelID = list[i];
                        label.NotesID = id;
                        label.UserID  = objtbl.UserID;
                        applicationDbContext.tblLabelNotes.Add(label);
                        result = await applicationDbContext.SaveChangesAsync();
                    }
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }

                return(result);
            }
            return(result);
        }
Exemple #20
0
        public async Task <int> AddNotes(tblNotes objtbl)
        {
            int result = 0;
            int status = 0;

            try
            {
                if (objtbl.Mode == 1)
                {
                    applicationDbContext.tblNotes.Add(objtbl);
                    result = await applicationDbContext.SaveChangesAsync();

                    return(result);
                }
                //Delete Note Forever.
                if (objtbl.Mode == 2)
                {
                    tblNotes obj = applicationDbContext.tblNotes.Where <tblNotes>(t => t.ID == objtbl.ID).First();
                    applicationDbContext.tblNotes.Remove(obj);
                    result = await applicationDbContext.SaveChangesAsync();

                    return(result);
                }

                // Update Note:Pinned note,delete note.
                if (objtbl.Mode == 3)
                {
                    tblNotes obj = applicationDbContext.tblNotes.Where <tblNotes>(t => t.ID == objtbl.ID).First();
                    obj.Title     = objtbl.Title;
                    obj.ID        = objtbl.ID;
                    obj.UserID    = objtbl.UserID;
                    obj.Content   = objtbl.Content;
                    obj.ColorCode = objtbl.ColorCode;
                    obj.IsPin     = objtbl.IsPin;
                    obj.IsTrash   = objtbl.IsTrash;
                    obj.IsArchive = objtbl.IsArchive;
                    obj.ID        = objtbl.ID;
                    obj.Reminder  = objtbl.Reminder;
                    obj.ImageUrl  = objtbl.ImageUrl;

                    result = await applicationDbContext.SaveChangesAsync();

                    return(result);
                }

                // Add collaborator
                if (objtbl.Mode == 5)
                {
                    AccountService accountService = new AccountService();
                    string         ShareWth       = string.Empty;

                    // Get the Email to whome want to share from dialog text enter.
                    string[] email = objtbl.share.Split();
                    ShareWth = objtbl.share.Split().Last();

                    // Get the data of whome want to share.
                    ApplicationUser ShareWithdata = await accountService.GetUser(ShareWth, 1);

                    // if Email is not valid
                    if (ShareWithdata == null)
                    {
                        // return result = "Email not register";
                    }


                    if (objtbl.owner == null)
                    {
                        ApplicationUser ownerData = await accountService.GetUser(objtbl.UserID, 2);

                        objtbl.owner = ownerData.Email;
                    }

                    tblNotes obj = applicationDbContext.tblNotes.Where <tblNotes>(t => t.ID == objtbl.ID).First();
                    obj.Title     = objtbl.Title;
                    obj.ID        = objtbl.ID;
                    obj.UserID    = objtbl.UserID;
                    obj.Content   = objtbl.Content;
                    obj.ColorCode = objtbl.ColorCode;
                    obj.IsPin     = objtbl.IsPin;
                    obj.IsTrash   = objtbl.IsTrash;
                    obj.IsArchive = objtbl.IsArchive;
                    obj.ID        = objtbl.ID;
                    obj.Reminder  = objtbl.Reminder;
                    obj.ImageUrl  = objtbl.ImageUrl;
                    obj.Label     = objtbl.Label;
                    obj.owner     = objtbl.owner;
                    obj.share     = objtbl.share;

                    //  applicationDbContext.tblNote.Add(obj);
                    status = await applicationDbContext.SaveChangesAsync();

                    // Add note to Share with User.
                    if (status != 0)
                    {
                        obj.UserID = ShareWithdata.Id;
                        obj.share  = ShareWth;

                        applicationDbContext.tblNotes.Add(obj);
                        status = await applicationDbContext.SaveChangesAsync();

                        //   return "Shared Successfully";
                    }

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


            return(result);
        }