private CodeJewelModelFull DesirializeCodeJewelToFull(CodeJewel codeJewel) { double averageVote = 0; if (codeJewel.Votes.Count>0) { averageVote = codeJewel.Votes.Average(v => v.VoteValue); } string category = "No Category"; if (codeJewel.Category!= null) { category = codeJewel.Category.Name; } CodeJewelModelFull modelFull = new CodeJewelModelFull { AuthorName = codeJewel.AuthorMail, CodeJewel = codeJewel.SourceCode, Id = codeJewel.Id, AverageVote = averageVote, category = category }; return modelFull; }
private CodeJewelModel DesirializeCodeJewel(CodeJewel code) { CodeJewelModel model = new CodeJewelModel { AuthorName = code.AuthorMail, CodeJewel = code.SourceCode, Id = code.Id }; return model; }