architecture – Separation of concerns and other best practices between controllers, services, suppliers and stores in ASP.NET when creating a REST Web API

I have traditionally been a developer of desktop applications, but circumstances have driven me to make the web client and the corresponding REST API logic for a project in which I am involved. Unfortunately, I am a one-man show, so my opportunities to learn new models or techniques from colleagues are somewhat limited. When I was ramping up, I had the opportunity to work (briefly) with an entrepreneur who exposed me to the idea that my server REST logic should be separated into one Controller (where the actual GET / PUT / POST / DELETE methods live) and a A service who does most of the work. As I was told, the A service could still interact with one or more Suppliers or Stores.

My understanding is that a Provider would encapsulate the logic that interacts with another system, maybe another web API, or a little weird legacy code, or maybe a little bit of proprietary hardware (like a temperature gauge, for example). In addition, a Shop would pack CRUD logic for real data objects in SQL, NoSQL, text files, whatever.

Assuming all of this makes sense, and this is actually the way the pros do it, he further advised me to incorporate the denomination into my lessons, like this:

PizzaController can proxy received web API calls to the PizzaService, who in turn could speak to both PizzaProvider and the RefridgeratorStore.

I'm not 100% positive, that's how the real world does things – but it made enough sense for me to appear believable and I have generally adopted this model and up to now it has worked well enough to organize my logic.

But this is where some questions arise:

First, is this vision of class separation really the way others structure their code? And if I am close, but not quite, what corrections should I make?

Second, is it legitimate for a A service to instance and take advantage of a second A service? For example, if my PizzaService must decide if we want delivery or if we're going to make pizza from scratch – he may want to invoke the PizzaProvider -or- he might just want to defer to the PizzaMakerService. If the PizzaService does not make this decision, so the logic of decision should live earlier in the food chain (no pun intended). It would infer my PizzaController will have to decide whether to use the PizzaService -or there PizzaMakerService; and it doesn't feel right to me.

And finally, (following the model that was shown to me) my Services frequently return a data object to my Controller, where the Controller will map one or more properties to a ViewModel who returned to my client. I discovered that I could just as easily map the relevant data bits into an anonymous object (C #) on the fly and return it to my client. The JSON returned is the same, so why introduce the class definition for a ViewModel at all? Is there a taboo against creating an anonymous object in the Controller and return it?

I realize (in my situation) that I can pretty much do whatever I want – how I name the classes, how I separate the logic, if I use anonymous objects – it's really entirely my code. But these questions have been pestering me for quite some time and I would like to make things as close as possible to "properly". It is likely that these questions (or a variation) have been asked and answered before, so I apologize now for any duplication – but for the life of me, I can't seem to find direct answers.

Thank you!

search – Stores the variable according to the search delimited in C

From my position:

char extraer_info(const char* adaptador)
    FILE* fp;
    const char* const Delim = "Adaptador";
    const char* terms() = {
    "Servidores DNS",

    fp = fopen("ip.out.txt", "r");
    char line(256);
    while (fgets(line, sizeof line, fp))
        for (const char** p = terms; *p; ++p)
            if (strstr(line, *p))
                fputs(line, stdout);

    return 0;

I access a redirected file which contains the information of my adapters. How could I implement delimiters so that instead of printing the line that meets my search parameters (those defined in "terms"), it stores the value between ":" and the line break ? For example, with regard to DNS servers, they can occupy different lines. How can I represent them?

That is to say, given the text string in my file that I am accessing:

   Direcci¢n IPv4. . . . . . . . . . . . . . : 192.168.1.XX(Preferido) 

The text contained between ":" and the end of this information. In the case of DNS, from ":" to the first non-integer character:

Servidores DNS. . . . . . . . . . . . . . : 80.XX.XX.XXX
   NetBIOS sobre TCP/IP. . . . . . . . . . . : ...

python – Create a file that stores variables and import them

I'm still learning Python, and now I have a new question. If for example you wanted to assign a variable a value determined by input () and then you wanted to save this variable in a file to import it, what could you do?

#El usuario asigna una variable con valor determinado
variable_x = input("Introduce un valor:")

#Se crea el archivo y se le almacena la variable
archivo = open("", 'w')

#Se importa la variable
from '' import *

The problem is, just because the variable is entered via the input, I can't give it a default value and I don't know how to make it accept the input. Greetings and thanks again!

optimization – Purchase of ingredients for a cake in many different stores and need to minimize the number of stores – name of the algorithm?

Let's say I prepare a cake and that it contains a few ingredients (including multiples):

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

I can go to several 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 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 bin packaging problem. It is a similar problem but not quite the same.

Any idea would be appreciated.

The downside is that stores needing a face covering are an infringement of freedom. Do they know that stores have always required that the body and feet be covered?

Yes, it is very different. This has always been reserved for patient visits to hospitals with highly contagious conditions so as not to simply trade. I have news for you that the mask does not protect you unless you have ADD and need to pick and eat the scars on your liberal face.

Should gun stores be deemed non-essential and closed?

It seems that the only people who think that armory is essential are those who already have firearms. Idiot. If you don't already own a gun, now is not the time to buy one. Having an unknown weapon while stressed and isolated is a very bad idea.

It's funny how my dentist is closed except in case of an emergency. Same thing with my ophthalmologist, but people who have brain bullets think gun stores are essential. Most people do not have a gun (70%) and most (57%) live in a household without a gun. And two-thirds of the 30% who own guns own more than one gun. Ammunition can be purchased online. How on earth is a gun store essential and not a dentist? Difficult to fill a cavity or to have your teeth cleaned on the Internet.

There is an obvious joke that could be made about it but I will not do it.

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

I currently have a magento 1.9 installation that uses two stores. I am currently trying to move a category (as well as subcategories and products) from one store to another, but I am having problems. At the moment, several subcategories are missing and are not displayed correctly on the category page.

What I've tried so far is just to move the folder and change the file used for the static block to make sure they are the same between both sites. What more could I miss?

Thanks in advance.

How to create an XML sitemap in Magento for several stores? [duplicate]

I created the site map for several stores in the format below Because there are several stores was created from an administrator and there is no Option to create multiple files by filename sitemap.xml for each country, so I need to follow the following, please check.

Will it work?

c – Stores several Boolean states in a single Boolean variable

The type bool both in C as in C++ consumes at least 1 byte of memory to store, I saw that it is because it needs to be addressed or something. So, would this byte store more than one Boolean state since true / false would only need 1 bit?

postgresql – Time stored using now () function :: timestamp stores incorrect value

I am using AWS RDS for a PostgreSQL 11 database with PGAdmin. I store the creation date of each line using now()::timestamp to store date and time without time zone. The problem is that the stored time is never the value I want (UTC+05:30).

If I set the parameter timezone as UTC in RDS, then the time stored is 5:30 am compared to the time in India, but if I set UTC + 5:30, it stores either 11 hours late or 1 hour off plus, this happens randomly on random lines. I haven't changed anything else, just that timezone setting.

I have searched a lot but I have not found a similar answer.