architecture: separating concerns and other best practices between controllers, services, testers, and stores in ASP.NET when creating a REST web API

Traditionally I am a developer of desktop applications, but circumstances have led me to the function of making a web client and the corresponding REST api logic for a project I am involved in. Unfortunately, I am a one-man show, so my opportunities to learn co-workers' new patterns or techniques are somewhat limited. When it was increasing, I had the opportunity to work (briefly) with a contractor who exposed me to the idea that my server's REST logic should be separated into a Controller (where the actual GET / PUT / POST / DELETE methods live) and a Service that does the heavy lifting. As explained to me, the Service could further interact with one or more Providers or stories.

I understand that a Provider It would wrap logic that interacts with another system, maybe another web API, or some legacy code, or maybe some proprietary hardware bit (like a temperature gauge, for example). Also, a Store It would wrap the CRUD logic for real data objects to SQL, NoSQL, text files, whatever.

Assuming all of this makes sense, and it's actually how professionals do it, he advised me to incorporate the name into my classes, like so:

PizzaController could send the received web API calls to Pizza service, who in turn could talk so much with him Pizza supplier and the RefridgeratorStore.

I'm not 100% sure this is how the real world does things, but it made enough sense for me to appear credible and overall I've adopted this pattern and so far it has worked well enough to organize my logic.

But this is where some questions come in:

First, is this vision of separation of my classes really how others structure their code? And if I am close, but not entirely, what corrections should I make?

Second, is it legitimate for you? Service for example and take a second Service? For example, what if my Pizza service you have to decide if we want delivery or if we are going to make a pizza from scratch you may want to invoke Pizza supplier -or- you may simply want to defer to PizzaMakerService. If he Pizza service does not make this decision, so the decision logic would have to live in the food chain first (no pun intended). That would infer my PizzaController would have to decide whether to use the Pizza service -wave PizzaMakerService; and that doesn't smell good to me.

And finally, (following the pattern shown to me) my Services frequently return a data object to my Controller, where he Controller will assign one or more properties in a ViewModel that is returned to my client. I found that I could easily map the relevant data bits into an anonymous object (C #) on the fly and return it to my client. The returned JSON is the same, so why enter the class definition for a ViewModel absolutely? Is there a taboo against simply creating an anonymous object in the Controller and giving it back?

I realize (in my situation) that I can do almost anything I want: how do I name the classes, how do I separate the logic, if I use anonymous objects, is it really my code. But these questions have been bothering me for a while, and I'd like to be doing things as close as possible & # 39; correctly & # 39 ;. These questions (or a variation) are likely to have been asked and answered before, so I will apologize now for any duplication, but for the life of me, I can't seem to find any direct answers.

Thank you!

magento2: stores the expiration time of the external API in the custom module

I use ajax to get the access token from the external API. How can I store the expired time on the site and the ajax only calls back when the session expired?

test.js

/ helloworld / index / display is the controller that will get the entry from Store -> Configuration and call the external API using cURL

$.ajax({
    url: "/helloworld/index/display",
    type: "GET",
    complete: function (response) {
        access_token = response.responseText;
    }
});

optimization: you buy ingredients for a cake in many different stores and you need to minimize the number of stores: algorithm name?

So, let's say I'm baking a cake and it has some ingredients (including multiple ones):

ingredients = {sugar, sugar, baking powder, chocolate, flour, egg, egg}

I can go to many different stores to buy the ingredients. Each store has a different collection of ingredients to offer:

store_1 = {sugar, vanilla extract, olive oil, chocolate}
store_2 = {chocolate, chocolate, flour, egg}
store_3 = {flour, baking powder, sugar, sugar, sugar, egg}

Problem: I want to buy all the ingredients for the cake from minimum number of stores

I'm sure this is a common problem with existing algorithms but I can't seem to find anything other than the container packaging problem. It is a similar problem but not exactly the same.

Any insight would be appreciated.

usability – Online used book stores

I have to build a website for used books. I am conducting an investigation for it.

I am looking for websites with old and used books.

What online used book stores do you know of?

Which are the best and why do you like them?

What would you like to improve in terms of used online bookstores?

What is missing in the ones you know?

java – List of pet stores near the user's location in Android Studio

Would you like to know how to list establishments, for example, pet stores near the user's exact location?

I have been researching and I have not found how to do it or something that gives me a north, I know I should use the Google Maps API and play in a list view, but I am a beginner and I don't know exactly how to do it.

It would be basically like ifood does today, showing how many km are the restaurants.

I'm waiting, if you can help me …

Design of the table of users of the e-commerce database of various stores

I am developing a Restful api multi-store e-commerce platform.

I'm stuck on the layout of the user table.

Platform users have 3 different roles: administrator, customer and merchant.

The administrator user only has a username, password, email fields.

Merchant users have additional fields that are a commission, activeStates (pivot table between states and merchants), addressDetails, taxNumber, city_id, state_id.

Client users have additional fields that are a tax number, cart_Id, addressDetails, city_id, state_id. I found 2 ways to implement those tables.

Way 1

3 different tables as administrator, client, merchant.

Administration table;

id
username
name
password
email
passwordResetToken
resetTokenExpireTime

Customer's tab;

id
username
name
password
email
passwordResetToken
resetTokenExpireTime
cart_id
city_id
state_id
addressDetails
taxNumber

Merchant table;

id
username
name
password
email
passwordResetToken
resetTokenExpireTime
city_id
state_id
addressDetails
taxNumber
commission

Way 2

Only user table and for additional fields Merchant, customer tables.

User table;

id
username
name
password
email
passwordResetToken
resetTokenExpireTime

Table of clients;

cart_id
city_id
state_id
addressDetails
taxNumber
user_id

Merchant table;

city_id
state_id
addressDetails
taxNumber
commission
user_id

Advantages of Way 1

  • Only one login endpoint is sufficient for any user who is logged into the platform.
  • Just a sufficient JWT token creation method. Dynamic role-based endpoints

Way 1 downsides

  • I have to create an additional query for clients or commercial users.
  • For example; The customer user adds their cart to the item, then I have to search for the user first and find customer by user, then find the customer cart and add the item to the cart.
  • If the merchant wants to update their product, I first have to search for a user and find a merchant by user, then find the product by ID and user.

Advantages of Way 2

  • I don't have to create additional queries for customer or merchant users. If the customer's user adds their cart to the item, then I found the customer directly in the Customer table. I don't need to find a user before a client.

Way 2 downsides

  • 3 different login endpoints are required for users.
  • Encoded role-based endpoints
  • To create JWT tokens you need 3 different methods because the users are not related.
  • Extra table in the database

Therefore, I need advice for designing that database. Which of the ways I found is better or do you have different advice in this 2 way?

Should gun stores be considered nonessential and closed?

It seems that the only people who think gun shops are essential are those who already own guns. Fool. If you don't already own a gun, now is not the time to buy it. Possessing an unknown weapon while stressed and isolated is a very bad idea.

It's funny how my dentist is closed except in emergencies. Same thing with my eye doctor, but somehow people with brain bullets think gun shops are essential. Most people do not own a gun (70%) and the majority (57%) live in a home without a gun. And two thirds of that 30% who own weapons own more than one pistol. Ammunition can be purchased online. How the hell is a gun shop essential and a dentist is not? It is difficult to fill a cavity or clean your teeth over the Internet.

There is an obvious joke that could be made about that, but I won't.

mysql: shows the name / title of a data but stores its ID

I have two tables

Room

rRoomsID | rRoomTypeID

Type of room

rtRoomTypeID | rtRoomTitle

the Room Type The table is a drop-down list. I want to show rtRoomTitle in the drop-down list but when inserting data into the Room table, I want the corresponding rtRoomTypeID to be stored instead of rtRoomTitle.

magento 1.9 – How do I correctly move products and categories between stores in magento1?

I currently have a magento 1.9 installation that uses two stores. Right now I am trying to move a category (as well as subcategories and products) from one store to another, but I run into some problems. Currently, several subcategories are missing and are not displaying correctly on the categories page.

What I have tried so far is simply to move the folder and change the file used for the static block to ensure they are the same between the two sites. What more could be missing?

Thanks in advance.

How to create an XML sitemap in Magento for multiple stores?

I have created these sitemaps because there are multiple stores. There is only one administrator account for all stores and it does not allow me to create multiple file names "sitemap.xml".

  • www.example.co.uk/sitemap.xml
  • www.example.fr/french.xml
  • www.example.ie/ireland.xml

will this work?