Code Monkey home page Code Monkey logo

homely's Introduction

Pre-requisities

  • Git
  • Code editor (e.g Visual Studio / VSCode)
  • SQL Server 2014+
  • .NET 5

Exercise Description

The following code test was created to evaluate your abilities as a .NET Developer. Some of the areas that you'll be evaluated in are:

  • Creativity
  • Proactivity
  • Code quality
  • Code organization
  • Tooling choices
  • Ability to follow instructions
  • Attention to details

We would like you to solve each task as they appear below, and avoid doing early optimizations or refactoring unless specified or if it blocks your solution for a specific problem. If any code is copied from the internet, make sure to add a comment with a reference to where you sourced it from.

Please treat this project and the tasks below as if they were part of, or the beginning of a bigger application that you would build and support. That means, please write the code as you like to write it, not the way you think we would like you to write it.

Getting started

  1. Initialise a new git repository at the root of the folder and perform an initial commit.
  2. Restore the Backend-TakeHomeExercise.bak backup onto a SQL Server installation. There is a single table called Listings that you'll work with
  3. Open the TakeHomeExcercise.sln solution and confirm you can build and run the API. You should see "TODO" being returned from the /listings route.
  4. Happy coding. Good luck, and have fun! :)

Tasks


Task-01: Create an API endpoint to return paged listings

Status: Completed

Create an API endpoint that returns paged listings from the sample DB, given the following (optional) filters:

  • Suburb (e.g "Southbank")
  • CategoryType (e.g "Rental")
  • StatusType (e.g "Current")
  • Skip (e.g 0)
  • Take (e.g 10)

Fields should be validated for invalid input, and the API should return an appropriate HTTP response when validation fails.

An example URL might be: /listings?suburb=Southbank&categoryType=Rental&statusType=Current&take=10

The returned JSON should look like:

{
  "items": [
    {
      "listingId": 4,
      "address": "53-55 Ellison St, Clifton Beach QLD 4879", // combination of address fields
      "categoryType": "Residential", // 1 = Residential, 2 = Rental, 3 = Land, 4 = Rural
      "statusType": "Current", // 1 = Current, 2 = Withdrawn, 3 = Sold, 4 = Leased, 5 = Off Market, 6 = Deleted
      "displayPrice": "Mid to High $800,000's",
      "title": "Buy me now!"
    }
  ],
  "total": 1212
}
Assumptions: 
1.Total is the total count of the query (used for paging)
2. The response is sorted in the ascending order of the listingId

Used Entity Framework Core for ORM solution.
I have disabled EntityFramework TrackChanges feature while querying the SQL DB for this project. Alternatively, I could use Micro-ORM like Dapper - used EF Core as I'm more comfortable with building quries with LINQ
Used Automapper to map Listing Entity to DTO object

Task-02: Add caching by suburb

Status: Completed

A common use case for listings is returning current listings of a given type in a suburb. Because of this, we would like some basic caching adding to avoid the trip to the DB.

Please add this caching functionality, so that the following behavior occurs:

  1. App loaded
  2. GET: /listings?suburb=Southbank&categoryType=Residential&take=10 -> cache MISS
  3. GET: /listings?suburb=Southbank&categoryType=Residential&take=10 -> cache HIT
  4. GET: /listings?suburb=Southbank&categoryType=Rental&take=10 -> cache MISS
  5. GET: /listings?suburb=Southbank&categoryType=Rental&take=10 -> cache HIT
  6. GET: /listings?suburb=Southbank&categoryType=Rental&take=5 -> cache HIT
Used Memory cache with the cache key Listing_{suburb}_{categoryType}_{skip} to store previous query results
if for the same Listing_{suburb}_{categoryType}_{skip} combination, take value is greater than cached take value, DB is hit

Task-03: Add a new property shortPrice

Status: Completed

We would like a new prop added to the payload:

{
   ... // existing props
   "shortPrice": "$800k"
}

This is a short version of the displayPrice, to be used on things like the pin display.

Minimum scenarios to handle:

displayPrice shortPrice
$100 $100
$100,000 $100k
$1,500,000 $1.5m
For Sale NULL

Bonus points for handling other scenarios (use your judgement as to what the value should be)

Added GetShortPrice() helper method in AutoMapper configuration file to convert display price to short price

Task-04: Tests

Status: Pending

It is expected that you write tests for important changes you made above on the previous tasks, if any test was relevant. As a last pass, please check any code, existing or new that would benefit from tests and write them. Explain below the benefits of the tests you wrote and why they are important.

Add comments here

homely's People

Contributors

tiju-devbench avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.