public AddNotesModel AddUserNote(AddNotesModel note) { try { return(AddUserNoteTask(note).Result); } catch (Exception) { throw; } }
public ActionResult EditNotes(string noteid, AddNotesModel notesModel, HttpPostedFileBase dp, HttpPostedFileBase uploadnote, HttpPostedFileBase notepreview) { if (Session["Id"] != null) { int id = Convert.ToInt32(Session["Id"].ToString()); using (projectEntities1 db = new projectEntities1()) { MembersData usr = db.MembersDatas.Where(u => u.Id == id).FirstOrDefault(); { NoteDetail notes = db.NoteDetails.Where(u => u.NoteTitle == noteid).FirstOrDefault(); { notes.Status = "Inreview"; string fileName = Path.GetFileName(dp.FileName); notesModel.dppath = "~/images/" + fileName; fileName = Path.Combine(Server.MapPath("~/images/"), fileName); dp.SaveAs(fileName); string fileName1 = Path.GetFileName(uploadnote.FileName); notesModel.uploadpath = "~/images/" + fileName1; fileName = Path.Combine(Server.MapPath("~/images/"), fileName1); uploadnote.SaveAs(fileName); string fileName2 = Path.GetFileName(notepreview.FileName); notesModel.notepath = "~/images/" + fileName2; fileName = Path.Combine(Server.MapPath("~/images/"), fileName2); notepreview.SaveAs(fileName); notes.ApprovedDate = DateTime.Now; notes.DisplayPic = notesModel.dppath; notes.Preview = notesModel.notepath; notes.note = notesModel.uploadpath; db.SaveChanges(); return(RedirectToAction("SearchNotes", "NoteDetails")); } } } } else { return(View()); } }
public async Task <IActionResult> Post([FromBody] AddNotesModel request, CancellationToken cancellationToken = default) { _logger.LogTrace($"{nameof(AddNotesController)}.{nameof(Post)} hit"); var errors = request.Validate(); if (errors.Any()) { return(BadRequest(errors)); } var response = await _command.ExecuteAsync(request, cancellationToken); return(Ok(response)); }
public async Task <AddNotesModel> AddUserNoteTask(AddNotesModel note) { try { if (note.IsTrash || note.IsArchive) { note.IsPin = false; } await redis.RemoveNotesRedisCache(note.Id); return(notesRL.AddUserNote(note)); } catch (Exception ex) { throw ex; } }
public IActionResult AddUserNote(AddNotesModel note) { try { var identity = User.Identity as ClaimsIdentity; if (identity != null) { IEnumerable <Claim> claims = identity.Claims; long Id = Convert.ToInt64(claims.Where(p => p.Type == "Id").FirstOrDefault()?.Value); note.Id = Id; AddNotesModel result = noteBL.AddUserNote(note); return(Ok(new { success = true, Note = result })); } return(BadRequest(new { success = false, Message = "no user is active please login" })); } catch (Exception exception) { return(BadRequest(new { success = false, exception.Message })); } }
public ActionResult EditNotes(int noteid, AddNotesModel notesModel) { if (Session["Id"] != null) { int id = Convert.ToInt32(Session["Id"].ToString()); using (projectEntities1 db = new projectEntities1()) { MembersData usr = db.MembersDatas.Where(u => u.Id == id).FirstOrDefault(); { NoteDetail nd = db.NoteDetails.Where(u => u.Id == noteid).FirstOrDefault(); { ViewData["Category"] = db.Categories.ToList <Category>(); ViewData["Type"] = db.Types.ToList(); ViewData["Country"] = db.Countries.ToList(); notesModel.country = nd.Country; notesModel.category = nd.Category; notesModel.coursecode = nd.CourseCode; notesModel.coursename = nd.Course; notesModel.Disc = nd.Description; notesModel.instituename = nd.University; notesModel.Noofpage = nd.NoOfPages; notesModel.price = nd.SellPrice; notesModel.professor = nd.Professor; notesModel.Title = nd.NoteTitle; notesModel.type = nd.Type; return(View(notesModel)); } } } } else { return(View()); } }
public async Task <AddNotesResponse> ExecuteAsync(AddNotesModel request, CancellationToken cancellationToken = default) { _logger.LogInformation($"Getting User: {request.UserId}"); var user = _userRepository.Get(new[] { request.UserId }).FirstOrDefault(); if (user == null) { _logger.LogWarning($"User: {request.UserId} does not exist"); return(new AddNotesResponse { UserId = request.UserId, Success = false }); } _logger.LogInformation("Creating new notes"); var notes = request.Notes.Select(note => new Note { NoteText = note.Text, }).ToList(); _logger.LogInformation($"Adding notes to user: {user.Id}"); foreach (var note in notes) { user.Notes.Add(note); } _logger.LogInformation("Saving changes to data store"); await _userRepository.SaveChangesAsync(cancellationToken); return(new AddNotesResponse { NoteIds = notes.Select(note => note.Id).ToList(), UserId = user.Id, Success = true }); }
public ActionResult AddNotes(AddNotesModel notesModel, HttpPostedFileBase dp, HttpPostedFileBase uploadnote, HttpPostedFileBase notepreview) { if (Session["Id"] != null) { int id = Convert.ToInt32(Session["Id"].ToString()); using (projectEntities1 db = new projectEntities1()) { MembersData usr = db.MembersDatas.Where(u => u.Id == id).FirstOrDefault(); { //projectEntities1 db = new projectEntities1(); NoteDetail notes = new NoteDetail(); ViewData["Category"] = db.Categories.ToList <Category>(); ViewData["Type"] = db.Types.ToList(); ViewData["Country"] = db.Countries.ToList(); notes.Category = notesModel.category; notes.Type = notesModel.type; notes.Country = notesModel.country; notes.OwnerId = id; notes.SellFor = false; notes.ReqDate = DateTime.Now; notes.ApprovedDate = DateTime.Now; notes.IsActive = true; notes.NoteTitle = notesModel.Title; notes.NoOfPages = notesModel.Noofpage; notes.Description = notesModel.Disc; notes.University = notesModel.instituename; notes.Course = notesModel.coursename; notes.CourseCode = notesModel.coursecode; notes.Professor = notesModel.professor; notes.SellPrice = notesModel.price; notes.Status = "Drafted"; string fileName = Path.GetFileName(dp.FileName); notesModel.dppath = "~/images/" + fileName; fileName = Path.Combine(Server.MapPath("~/images/"), fileName); dp.SaveAs(fileName); db.NoteDetails.Add(notes); string fileName1 = Path.GetFileName(uploadnote.FileName); notesModel.uploadpath = "~/images/" + fileName1; fileName = Path.Combine(Server.MapPath("~/images/"), fileName1); uploadnote.SaveAs(fileName); db.NoteDetails.Add(notes); string fileName2 = Path.GetFileName(notepreview.FileName); notesModel.notepath = "~/images/" + fileName2; fileName = Path.Combine(Server.MapPath("~/images/"), fileName2); notepreview.SaveAs(fileName); db.NoteDetails.Add(notes); notes.DisplayPic = notesModel.dppath; notes.Preview = notesModel.notepath; notes.note = notesModel.uploadpath; db.SaveChanges(); return(View()); } } } else { return(View()); } }