项目作者: Tsvetilin

项目描述 :
Web application for sharing films and cinemas
高级语言: C#
项目地址: git://github.com/Tsvetilin/CinemaShare.git
创建时间: 2020-04-29T17:23:14Z
项目社区:https://github.com/Tsvetilin/CinemaShare

开源协议:

下载


CinemaShare

ASP.NET Core MVC Web application for sharing, rating and reviewing films, adding projections in registered cinemas and reserving tickets

Description

Made as an exam project for IT Career Module 7 “Software Development” by Tsvetilin Tsvetilov, Stoyan Zlatev and Pavlin Marinov

Stucture of the project

Three-tier architecture

Data Layer

  • Code First
  • MySql Database
  • Entity Framework
  • Data Seeding

Service Layer

  • Web APIs

    • SendGrid
      Email sending
    • OMDb
      Film data fetching from IMDb
    • Cloudinary
      Uploading user’s images in the cloud
  • Template model converting

    • Default service method
      1. public async Task<FilmData> GetAsync(string id)
      2. {
      3. return await context.FilmDatas.FindAsync(id);
      4. }
    • Model templated service method
      1. public async Task<TModel> GetAsync<TModel>(string id, Func<FilmData, TModel> mapToModelFunc)
      2. {
      3. var film = await GetAsync(id);
      4. return mapToModelFunc(film);
      5. }

Presentation Layer

  • ASP.NET Core 3.0
  • Custom Mapper
    • Default mapping method
      1. private TToModel MapSimilarProperties<TFromModel, TToModel>(TFromModel fromObject)
      2. where TFromModel : class
      3. where TToModel : class, new()
      4. {
      5. TToModel model = new TToModel();
      6. if (fromObject != null)
      7. {
      8. PropertyInfo[] props = fromObject.GetType().GetProperties();
      9. var modelType = model?.GetType();
      10. foreach (var prop in props)
      11. {
      12. var modelProperty = modelType?.GetProperty(prop.Name);
      13. if (modelProperty?.PropertyType?.Equals(prop.PropertyType) ?? false)
      14. {
      15. modelProperty.SetValue(model, prop.GetValue(fromObject));
      16. }
      17. }
      18. }
      19. return model;
      20. }
    • Mapping Entity model to View model example
      1. public ExtendedFilmCardViewModel MapToExtendedFilmCardViewModel(FilmData filmData)
      2. {
      3. var viewModel = MapSimilarProperties<FilmData, ExtendedFilmCardViewModel>(filmData);
      4. if (filmData != null)
      5. {
      6. viewModel.Id = filmData.FilmId;
      7. viewModel.Genres = string.Join(", ", filmData.Genre.Select(a => a.Genre.ToString()));
      8. viewModel.Rating = Math.Round(filmData.Film.Rating, 1).ToString();
      9. }
      10. return viewModel;
      11. }

Unit Testing

  • NUnit tests
    • 70% code coverage
  • Moq Database mockup