public async Task <int> UpdateNote(tblNote model) { int i = 0; try { tblNote tbl = dbContext.tblNotes.Where <tblNote>(a => a.ID == model.ID).First(); tbl.Title = model.Title; tbl.Content = model.Content; tbl.UserID = model.UserID; tbl.ColorCode = model.ColorCode; tbl.IsTrash = model.IsTrash; tbl.IsPin = model.IsPin; tbl.IsDelete = model.IsDelete; tbl.IsArchive = model.IsArchive; tbl.Reminder = model.Reminder; tbl.ImageUrl = model.ImageUrl; //tbl.Reminder = Convert.ToString(DateTime.Now.ToShortTimeString()); //tbl.Reminder = Convert.ToString(DateTime.Now.ToString("MMMM"))+", "+ Convert.ToString(DateTime.Now.ToShortTimeString()); tbl.UserID = model.UserID; i = await dbContext.SaveChangesAsync(); return(i); } catch (Exception ex) { ex.ToString(); } return(i); }
//POST: api/NotesApi/AddNote public async Task <int> AddNote(tblNote model) { int i = 0; try { if (model.Mode == "1") { i = await _noteRepository.AddNote(model); return(i); } if (model.Mode == "2") { i = await _noteRepository.UpdateNote(model); return(i); } if (model.Mode == "3") { i = await _noteRepository.DeleteNote(model); return(i); } } catch (Exception ex) { Logger.Write(ex.ToString()); } return(i); }
public ActionResult AddNote(TasksViewModel model) { string userid = ""; if (Session["userId"] != null) { userid = Session["userId"].ToString(); } int userID = int.Parse(userid); var person = pocoDb.Fetch <tblUser>(" WHERE userID = @0", userID).FirstOrDefault(); var personId = person.PersonID; if (ModelState.IsValid) { tblNote Note = new tblNote(); Note.noteText = model.Note.noteText; Note.objectTypeID = 11; Note.createdDate = DateTime.Now; Note.objectID = model.Note.objectID; Note.PersonID = personId; Note.createdByID = personId; pocoDb.Insert(Note); } return(RedirectToAction("detailTask", "Task", new { id = model.Note.objectID })); }
public bool Save(Note_DTO note_dto) { tblNote note = Convert_Note.Convert(note_dto); _dbcontext.tblNotes.Add(note); _dbcontext.SaveChanges(); return(true); }
public bool Save(string row_id, string table_name, string note, string user_id) { tblNote tblnote = new tblNote { Table_Name = table_name, Table_Row_Id = row_id, Comments = note, User_Id = user_id, Last_Updated = System.DateTime.Now }; _dbcontext.tblNotes.Add(tblnote); _dbcontext.SaveChanges(); return(true); }
public async Task <string> PostImage() { 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"]; tblNote model = new tblNote(); var url = RequestContext.Url.Request.RequestUri.Authority; //var returnurl = url.Scheme + "://" + url.Host + ":" + url.Port + "/api/NotesApi/GetNotes"; 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 = "2"; model.Reminder = Reminder; model.IsPin = Convert.ToInt16(IsPin); } NotesController notesController = new NotesController(); await notesController.GetNotes(model); return(model.ImageUrl); }
public async Task DeleteNote() { NotesApiController notesController = new NotesApiController(); tblNote tblNote = new tblNote(); tblNote.ID = 7; tblNote.Mode = "3"; tblNote.IsDelete = 1; var result = await notesController.AddNote(tblNote); Assert.AreEqual(1, result); }
public async Task <int> DeleteNote(tblNote model) { int i = 0; try { tblNote tbl = dbContext.tblNotes.Where <tblNote>(a => a.ID == model.ID).First(); dbContext.tblNotes.Remove(tbl); i = await dbContext.SaveChangesAsync(); } catch (Exception ex) { ex.ToString(); } return(i); }
//POST: api/NotesApi/AddNote public async Task <int> AddNote(tblNote model) { int i = 0; try { i = await _noteRepository.AddNote(model); return(i); } catch (Exception ex) { Logger.Write(ex.ToString()); } return(i); }
public async Task <int> AddNote(tblNote model) { int i = 0; try { dbContext.tblNotes.Add(model); i = await dbContext.SaveChangesAsync(); return(i); } catch (Exception ex) { ex.ToString(); } return(i); }
public async Task <int> ConsumePostApi(tblNote model, string token) { try { var client = new HttpClient(); //var url = Request.Url; //var returnurl = "https://localhost:44399/api/NotesApi/AddNote"; string returnurl = CurrentUrl + "/api/NotesApi/AddNote"; 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", 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>("UserID", model.UserID) }; var content = new FormUrlEncodedContent(body); HttpResponseMessage response = await client.PostAsync(returnurl, content); return(1); } catch (Exception ex) { Logger.Write(ex.ToString()); ex.ToString(); } return(0); }
public async Task UpdateNote() { NotesApiController notesController = new NotesApiController(); tblNote tblNote = new tblNote(); tblNote.ID = 9; tblNote.Title = "repos"; tblNote.Content = "hello,hey"; tblNote.IsPin = 0; tblNote.ColorCode = "white"; tblNote.Mode = "2"; tblNote.IsTrash = 0; tblNote.IsActive = 0; var result = await notesController.AddNote(tblNote); Assert.AreEqual(1, result); }
public async Task AddNote() { NotesApiController notesController = new NotesApiController(); tblNote tblNote = new tblNote(); tblNote.Title = "testnote"; tblNote.Content = "this is my content"; tblNote.IsPin = 0; tblNote.ColorCode = "black"; tblNote.Mode = "1"; tblNote.IsTrash = 1; tblNote.IsActive = 0; var result = await notesController.AddNote(tblNote); Assert.AreEqual(1, result); Assert.IsNotNull(result); }
public async Task <ActionResult> GetNotes(tblNote model) { var i = 0; try { if (ModelState.IsValid) { i = await accountController.ConsumePostApi(model); return(View()); } } catch (Exception ex) { Logger.Write(ex.ToString()); } return(View(i)); }
public async Task <ActionResult> GetNotes(tblNote model) { var i = 0; try { //string token = TempData["access_token"].ToString(); //string userid = TempData["UserID"].ToString(); //TempData.Keep(); model.UserID = userid; if (ModelState.IsValid) { i = await accountController.ConsumePostApi(model, token); return(View()); } } catch (Exception ex) { Logger.Write(ex.ToString()); } return(View(i)); }
public List <tblNote> GetNotes(string userid) { var list = new List <tblNote>(); try { //list = dbContext.tblNotes.OrderBy(a => a.ID).ToList<tblNote>(); tblNote tblNote = new tblNote(); var data = from a in dbContext.tblNotes where a.UserID == userid select a; foreach (tblNote item in data) { list.Add(item); } return(list); } catch (Exception ex) { ex.ToString(); } return(list); }
public Note_DTO GetLastNote(int id) { tblNote tbl_note = _dbcontext.tblNotes.Where(note => note.Id == id).OrderByDescending(order => order.Last_Updated).SingleOrDefault(); return(Convert_Note.Convert(tbl_note)); }
public Note_DTO Get(int id) { tblNote tbl_note = _dbcontext.tblNotes.SingleOrDefault(note => note.Id == id); return(Convert_Note.Convert(tbl_note)); }
public Task <int> UpdateNote(tblNote model) { throw new NotImplementedException(); }
public void AddTotblNotes(tblNote tblNote) { base.AddObject("tblNotes", tblNote); }
public static tblNote CreatetblNote(int noteID, int ID) { tblNote tblNote = new tblNote(); tblNote.NoteID = noteID; tblNote.id = ID; return tblNote; }
public static Note_DTO Convert(tblNote note_tbl) { return(Mapper.Map <tblNote, Note_DTO>(note_tbl)); }