public Appointment Read(uint id) { List <string[]> data = Persistence.ReadEntryByPrimaryKey(path, id.ToString()); if (data.Count == 1) { uint appID = uint.Parse(data[0][0]); DateTime startTime = new DateTime(long.Parse(data[0][1])); DateTime endTime = new DateTime(long.Parse(data[0][2])); uint mrID = uint.Parse(data[0][3]); uint docID = uint.Parse(data[0][4]); Doctor d = (Doctor)PeopleRepository.GetInstance().Read(docID); uint roomID = uint.Parse(data[0][5]); //TODO: room read Room r = RoomRepository.GetInstance().Read(roomID); ServiceComment comm = null; if (!data[0][6].Equals("")) { uint commID = uint.Parse(data[0][6]); //TODO: comment read comm = ServiceCommentRepository.GetInstance().Read(commID); } Appointment ret = new Appointment(startTime, endTime, mrID, d, r, comm); ret.SetId(appID); return(ret); } return(null); }
public static CommentModel GetCommentModel(ServiceComment comment) { UserShortModel user = manager.userService.GetUserProfile(comment.UserID)?.ToUserShortModel() ?? new ServiceUserProfile() { ID = comment.UserID }.ToUserShortModel(); return(comment.ToCommentModel(user, Book.GetBookShortModel(comment.BookID, comment.UserID))); }
public static CommentModel ToCommentModel(this ServiceComment comment, UserShortModel user, BookShortModel book) { return(new CommentModel { PublishTime = comment.PublishTime, Book = book, ID = comment.ID, Text = comment.Text, User = user }); }
public static DalComment ToDalComment(this ServiceComment comment) { return(new DalComment { ID = comment.ID, BookID = comment.BookID, UserID = comment.UserID, Text = comment.Text, PublishTime = comment.PublishTime, }); }
private void addComment(int serviceId, string serviceProviderId, int servicePathId) { ServiceComment comment = new ServiceComment(); comment.CreatorId = serviceProviderId; comment.ServiceId = serviceId; comment.CreationDate = DateTime.Now; comment.LastModificationDate = DateTime.Now; comment.CreatorName = db.Users.Find(serviceProviderId).Name; comment.Text = db.ServicePaths.Find(servicePathId).Message != null?db.ServicePaths.Find(servicePathId).Message : ""; db.ServiceComments.Add(comment); }
// DELETE: odata/ServiceComments(5) public IHttpActionResult Delete([FromODataUri] int key) { ServiceComment ServiceComment = db.ServiceComments.Find(key); if (ServiceComment == null) { return(NotFound()); } db.ServiceComments.Remove(ServiceComment); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <CommandResult <CommentViewModel> > ExecuteAsync(CommentViewModel addComment) { var userId = _httpContextAccessor.HttpContext.User.Identity.Name; var userName = await _userManager.FindByIdAsync(userId); try { var comment = new ServiceComment { ContentOfRating = addComment.ContentOfRating, UserId = Guid.Parse(addComment.UserId), ServiceId = Guid.Parse(addComment.ServiceId), ParentId = addComment.ParentId }; await _commentRepository.Add(comment); await _commentRepository.SaveAsync(); var getOwnerService = await _getOwnServiceInformationQuery.ExecuteAsync(addComment.ServiceId); await LoggingUser <AddCommentServiceAsyncCommand> . InformationAsync(getOwnerService, userName.UserName, addComment.ContentOfRating); await Logging <AddCommentServiceAsyncCommand> .InformationAsync(ActionCommand.COMMAND_ADD, userName.UserName, JsonConvert.SerializeObject(addComment)); return(new CommandResult <CommentViewModel> { isValid = true, myModel = new CommentViewModel { ContentOfRating = comment.ContentOfRating, Id = comment.Id, ParentId = comment.ParentId, ServiceId = comment.ServiceId.ToString(), UserId = comment.UserId.ToString() } }); } catch (Exception ex) { await Logging <AddCommentServiceAsyncCommand> .ErrorAsync(ex, ActionCommand.COMMAND_ADD, userName.UserName, "Has error"); return(new CommandResult <CommentViewModel> { isValid = false, errorMessage = ex.InnerException.Message.ToString() }); } }
public void Enrich(IHalResponseBuilder halResponseBuilder, ServiceComment serviceComment, string serviceId) { if (halResponseBuilder == null) { throw new ArgumentNullException(nameof(halResponseBuilder)); } if (serviceComment == null) { throw new ArgumentNullException(nameof(serviceComment)); } halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetServiceComment(serviceComment), (l) => l.AddOtherItem("service", new Dtos.Link("/" + Constants.RouteNames.Services + "/" + serviceId)))); }
public ActionResult post(CommentViewModel commentvm) { commentvm.comment.user = ServiceUser.getUser(User.Identity.Name); commentvm.comment.zone = ServiceZone.GetZonedetached(commentvm.ZoneId); if (ModelState.IsValid) { ServiceComment.addComment(commentvm.comment); return(Redirect("/Suivi/Zone/" + commentvm.ZoneId)); } return(View(commentvm.comment)); }
// POST: odata/ServiceComments public IHttpActionResult Post(ServiceComment ServiceComment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ApplicationUser currentUser = core.getCurrentUser(); ServiceComment.CreationDate = DateTime.Now; ServiceComment.LastModificationDate = DateTime.Now; ServiceComment.CreatorId = core.getCurrentUser().Id; ServiceComment.ModifierId = core.getCurrentUser().Id; ServiceComment.CreatorName = core.getCurrentUser().Name; db.ServiceComments.Add(ServiceComment); db.SaveChanges(); return(Created(ServiceComment)); }
public async Task Handle(AddServiceCommentCommand message) { if (message == null) { throw new ArgumentNullException(nameof(message)); } var record = await _serviceRepository.Get(message.ServiceId); if (record == null) { return; } var serviceComment = new ServiceComment { Id = message.Id, Content = message.Content, Score = message.Score, Subject = message.Subject, CreateDateTime = message.CreateDateTime, UpdateDateTime = message.UpdateDateTime }; record.AddComment(serviceComment); await _serviceRepository.Update(record); _eventPublisher.Publish(new ServiceCommentAddedEvent { Id = message.Id, ServiceId = message.ServiceId, ShopId = record.ShopId, Content = message.Content, Score = message.Score, Subject = message.Subject, CreateDateTime = message.CreateDateTime, UpdateDateTime = message.UpdateDateTime, AverageScore = record.AverageScore, NbComments = record.Comments == null ? 0 : record.Comments.Count() }); }
// PUT: odata/ServiceComments(5) public IHttpActionResult Put([FromODataUri] int key, Delta <ServiceComment> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ServiceComment ServiceComment = db.ServiceComments.Find(key); if (ServiceComment == null) { return(NotFound()); } patch.Put(ServiceComment); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ServiceCommentExists(key)) { return(NotFound()); } else { throw; } } return(Updated(ServiceComment)); }
public void RemoveComment(ServiceComment comment) { unit.Comments.Delete(comment.ToDalComment()); unit.Save(); }
public void AddComment(ServiceComment comment) { unit.Comments.Create(comment.ToDalComment()); unit.Save(); }
public Appointment(DateTime startTime, DateTime endTime, uint medicalRecordId, Doctor doctor = null, Room room = null, ServiceComment serviceComment = null) { this.startTime = startTime; this.endTime = endTime; this.id = 0; this.medicalRecordId = medicalRecordId; this.doctor = doctor; this.room = room; this.serviceComment = serviceComment; }