/// <summary>
 /// Method ToDalVoting convert VotingEntity to DalVoting.
 /// </summary>
 /// <param name="votingEntity">VotingEntity that need convert.</param>
 /// <returns>DalVoting entity.</returns>
 public static DalVoting ToDalVoting(this VotingEntity votingEntity)
 {
     return(new DalVoting()
     {
         UserId = votingEntity.UserId,
         PhotoId = votingEntity.PhotoId,
         Rating = votingEntity.Rating
     });
 }
Beispiel #2
0
        public virtual void AssignFrom(VotingEntity entity)
        {
            if (entity == null) throw new ArgumentNullException(nameof(entity));

            this.Id = entity.Id;
            this.Reason = entity.Reason;
            this.VoteOptionId = entity.Option.Id;
            this.Staff = entity.Staff.ToViewModel(); 
            this.CreatedAt = entity.CreatedAt; 
        }
 /// <summary>
 /// Method Create create voting entity.
 /// </summary>
 /// <param name="votingEntity">New voting entity for create.</param>
 public void Create(VotingEntity votingEntity)
 {
     try {
         votingRepository.Create(votingEntity.ToDalVoting());
         uow.Commit();
     }
     catch (Exception ex) {
         logger.Error(logger.GetMessage("Create new Vote was failed.", this), ex);
     }
 }
 /// <summary>
 /// Method Update update exists voting.
 /// </summary>
 /// <param name="votingEntity">VotingEntity that need update.</param>
 public void Update(VotingEntity votingEntity)
 {
     try {
         votingRepository.Update(votingEntity.ToDalVoting());
         uow.Commit();
     }
     catch (Exception ex) {
         logger.Error(logger.GetMessage("Update vote for photo was failed.", this), ex);
     }
 }
        void IVotingAdditing.Add(VotingModel v)
        {
            long id = 1 + HousingCoo.Data.Services.Storage.Instance.Votings.Keys.Max();

            v.Id = id;
            VotingEntity entity = v.Map <VotingEntity>();

            HousingCoo.Data.Services.Storage.Instance.Votings.Add(id, entity);
            HousingCoo.Data.Services.Storage.Instance.Comments.Add(id, new List <CommentVotingEntity>());
        }