using ASHermed.AdminInterface.Api.ContractModel;
using ASHermed.SinoInterface.Api.ContractModel;
using ASHermed.SinoInterface.Api.ContractModel.App;
using ASHermed.SinoInterface.Api.ContractModel.Online.Entity;
using ASHermed.SinoInterface.Api.IRepository;
using ASHermed.SinoInterface.Api.IRepository.App;
using ASHermed.SinoInterface.Repository.MySql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ASHermed.SinoInterface.Api.MySqlRepository.App
{
    public class OnlineEvaluationRepository : BaseRepositoryToASHermed_SinoInterface<Online_Evaluation>, IOnlineEvaluationRepository
    {
        public List<Online_Evaluation> GetEvaluation(int userid)
        {
            var sql = @"SELECT * FROM online_evaluation
                        WHERE UserId = @UserId 
                        Order BY CreateTime DESC ";
            return Query<Online_Evaluation>(sql, new { UserId = userid }).ToList();
        }

        public int InsertEvaluation(Online_Evaluation model)
        {
            var sql = @"        INSERT INTO `online_evaluation` ( `UserId`, `PatId`, `Content`, `Score`, `EvaluationCH`, `EvaluationEN`, `CreateTime` )
                                 VALUES
	                            ( @UserId, @PatId, @Content, @Score, @EvaluationCH, @EvaluationEN, @CreateTime ) ";
            var parms = new Dictionary<string, object>();
            parms.Add("@UserId", model.UserId);
            parms.Add("@PatId", model.PatId);
            parms.Add("@Content", model.Content);
            parms.Add("@Score", model.Score);
            parms.Add("@EvaluationCH", model.EvaluationCH);
            parms.Add("@EvaluationEN", model.EvaluationEN);
            parms.Add("@CreateTime", model.CreateTime);
            return Insert(sql, parms);
        }
    }
}
