c# – System Design – ASP.Net MVC Preparations

I’m about to start an asp.net mvc project with Repositorty-Service pattern and I’m first gathering information. Therefore I’ve got few questions that I need clarification before I start implementing.

In my company, most of the asp.net mvc projects developed by senior developers possess common features such as :

So my questions are :

1) Do I always need a caching mechanism and logging and Security(Encryption – AES…) in an asp.net mvc app?

2) When do I need them? I mean in what situation do I need caching and logging and Security(Encryption)? please give me detailed answer for each for clarification.

3) Is it fine/professional to use in a real-world asp.net project, the default ASP.Net MVC authentication code that gets generated when you create a new asp.net app? as I’m building a quite big asp.net (not very big) web app with Repository-Service pattern and I just want to reuse the default MS ASP.Net authentication (to save me time) instead of writing a new one.

4) Do I need to use SQL Server or MongoDB as database? I know that MongoDB is best suited for scalability but I don’t want to use a library which I’ll be forced to dig in to its library DLL and modify some code in order to make it work, as I don’t want to waste my time as the project is timed.

design patterns – MVC who knows about whom?

The Model represents our application’s domain model. The View presents this information and the controller manipulates business logic.

Indeed, the view presents the user interface that presents this information.
But the controller processes the input from the user. THere’s no business logic in an MVC controler: the business logic is packed together with the domain model.

The MVC litterature is full of variants and misunderstandings. A very close pattern is the Entity-Boundary-Control pattern. An EBC controller indeed provides for business logic. But not a traditional MVC controler.

I do not understand from any diagram that I saw, who knows about whom. Does the View know about the Controller? Does the Controller know about the View?

The controller knows them all: the controler receives user input, interprets it and if requested, creates new views or sends commands to the model.

The view knows the model since it can query the model to present the relevant information. But it doesn’t have to know the controller.

The model knows the views, since the views can be observers of the model, so that they are notified when the model changes.

All I know is the Model should not know anything about the view, because those two should be independent. As for the opposite I’m not sure.

The model shall indeed not depend on the view: many view can exist for a given model. However, it shall know however how to notify the view. SO there is an interface dependency: the view shall implement the notification interface, whereas the model just needs to know the interface.

java – Is my approach seems logical? Where should I place Listeners to satisfy MVC and Observer Design Pattern?

I am trying to create a basic shared gallery program with Users where they can follow/unfollow each other and add Images to their favoriteImagesList. Whenever they choose an image on JList,it will be shown and comments of the Media object that contains the image will be shown beside. By selecting the comments they will be able to follow the owner of comment. From their profile page they will be able to unfollow them. When I am implementing I should satisfy Model View Controller and Observer Design Patterns. In this assignment the view and controller will be separate. When User follows another User from Profile tab should be refreshed. I can’t see how to use Observer Design with this requirements. In the examples shown in my lectures, all the listeners were placed in the Controller. I tried to build some structure but since I use custom subclasses of JPanel, the delegation chain gets longer, and I am having problem to update the objects when it is necessary. Can you please criticize and give some advises?

I know it is not fully containing and the proper class diagram but I am adding to show my approach.

enter image description here

Pages:

Login

Timeline

Profile

Controller which I try to place Listener classes:

public class Controller {

private LoginView loginView;
private Gallery tube;

public Controller(LoginView loginView,Gallery gallery) {
    this.loginView = loginView;
    this.gallery= tube;
    ((LoginView)loginView).addLoginListener(new LoginListener());
    ((Gallery )gallery).addUnfollowListener(new UnfollowListener());
    ((Gallery )gallery).addFollowListener(new FollowListener());
    ((Gallery )gallery).addCommentListener(new CommentListener());

}
class CommentListener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
    //System.out.println(tube.getCommentText());
    //currentUser ????
    //Comment newComment = new Comment(currentUser,gallery.getCommentText());
    //Video currentVideo = getVideo();
    //currentVideo.addComment(newComment);

   }
}
class UnfollowListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
        //unfollow situation
        //User unfollowedUser = gallery.unfollowSelectedUser();
    }
}
class FollowListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
        //follow situation
        //User followedUser = gallery.getFollowedUser();
    }
}
class LoginListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {    
        String username = "";
        String password;
            try {
                username = loginView.getUsername();
                password = new String(loginView.getPassword());

                //login situation   
            } catch (IllegalArgumentException ex) {
                loginView.showError("Wrong username or password.");
            }
    }
}

}

java – In my Spring MVC project, Tomcat takes 3 to 4 minutes to start / restart, how can it be improved?

I am using two databases MySql and MongoDB with the Spring MVC project. I checked my console and my log, it is taking too long for the MongoDB connection.

1.MySql connection code

@Bean
public DataSource restDataSource() {
    final BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName"));
    dataSource.setUrl(env.getProperty("jdbc.url"));
    dataSource.setUsername(env.getProperty("jdbc.user"));
    dataSource.setPassword(env.getProperty("jdbc.pass"));
    return dataSource;
}

@Bean
@Autowired
public HibernateTransactionManager transactionManager(final SessionFactory sessionFactory) {
    final HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory);
    return txManager;
}

2.MongoDB connection code

@Bean
public MongoDbFactory mongoDbFactory() throws UnknownHostException, java.net.UnknownHostException {
   return new SimpleMongoDbFactory(new MongoClientURI("mongodb://localhost:27017/dbname"));
}

@Bean
public MongoTemplate mongoTemplate() throws UnknownHostException, java.net.UnknownHostException {
    return new MongoTemplate(mongoDbFactory());
}       

Am I doing it the right way or not?

Asp.net MVC HTML editor

Can you help me figure out where i need to start to implement HTMl editor in MVC

PHP MVC OOP Design

My colleague gave me an API project to work on half the creation of a thin PHP system. The project includes models and controllers. When the route is called, it calls the controller with the necessary function in the controller, then queries the data in the database in the functions of the model and retrieves the response.

I want to know if this is the right way to implement OOP in PHP API applications? If not, what changes and components do I need to make to make it the OOP MVC app?

User controller

public function getUser($request, $response, $args)
{
    $user = $request->getAttribute('id');

    $user = $this->User->getUserById($userId);

    if (!$user) {
        return $response->withJSON((
          "error" => true, 
          "message" => "cannot get user info", 
          "data" => null
        )));
    }

    return $response->withJSON((
        "error" => false, 
        "message" => "cannot get user info"
        "data" => $user
    ));
}

User model

public function getUserById($userId)
{
    $sql = "SELECT id, name, email
            FROM users
            WHERE id= :id";

    try {
        $stmt = $this->db->prepare($sql);
        $result = $stmt->execute((
            'id' => $userId
        ));
        if ($result && $stmt->rowCount() == 1) {
            return $stmt->fetchAll()(0);
        } else {
            return false;
        }
    } catch (PDOException $e) {
        $this->logger->info("cannot get user by id from DB " . $e);
        return false;
    }
}

Design Templates – Am I structuring this correctly for a .net mvc web application based on onion architecture?

Text) (https://imgur.com/a/ikwByd8) (! (Enter the description of the image here) 1

I'm new to MVC. Most of my career, I have used web forms in Asp.net. Reading MVC was really confusing because from what I learned, in traditional MVC, the models were supposed to be business logic as well as the models / in-house domain objects. But when it comes to Microsoft's MVC, the model means that View Models and MVC is right in the UI / Presentation layer. Now, I'm trying to combine that with the Onion / Clean architecture. I use the Busines Logic layer and the Service layer interchangeably, but for the sake of simplicity for this application.

So my web application basically queries a few CSV files. These are the player data where we have the biographies of the tennis players and their match records and their head to head records. Besides the obvious display of data in the user interface layer inside the view, this data has to be displayed very differently from the way it is stored, let's assume that there is also business logic decisions that are processed at the service / business layer.

Assuming that the application will become much larger than its starting point, I decided to use the repository model and not go directly to the data source. The repository classes and the corresponding interfaces therefore reside in Data Access Layer. All of these are closely related to each other, so if we decide to switch from CSV files to SQL DB, much of this layer will have to be rewritten. It is, so to speak, an outer layer.

The innermost layer is the model / domain objects that make sense from a logical point of view and do not necessarily match 1 to 1 with how they are stored in the database nor how they are displayed in the view. The 3 layers DAL, BL, UI can directly access these model classes. However, these are in their own projects and these depend on nothing outside of this project. From what I understand, this is where ignoring the technology is important because we want to be able to change DAL without a single one without any modifications required for that particular layer.

DI is used both for the Business layer to be able to use DAL and for the UI layer to use the functionality of the Business layer. There are no such separate DTOs and instead domain model objects are used for this.

This is how I intend to configure it for scalability and SoC. Can someone please point out the disadvantages of this and if I understand things correctly?

asp.net mvc – Looking for the best Windows hosting service

I want to create websites for businesses and individuals. I want to know if any of them have experience with hosting services.

I have experience with Godaddy – they are cheap to start with, but as soon as additional service is done, for example. a certificate, they become very expensive.

Hosting service requirements:

  • Windows platform for MVC sites.
  • Competitive prices.
  • Good page speed.
  • Support hotline or e-mail.
  • Opportunity for the SQL server database (Microsoft).
  • SSL certificate for each site
  • Server placed in Europe.
  • E-mail address for an individual page – without advertising.

Thanks in advance.

c # – How to save the authorization values ​​of an API response in MVC Core 3?

I am trying to establish a connection with SAP Business One Service Layer, but when I try to make requests, it tells me that I do not have authorization .

When you play Postran, everything is fine.

enter description of image here

Here in the second image we see how a cookie is generated automatically, which I think is what I miss in my MVC Core application.

enter description of image here

When I try to do it in my project, the connection if it works correctly and I get the same answer

enter description of image here

But when I do the GET to get the other information, I get the following error.
enter description of image here

This is my full code

enter description of image here

asp.net mvc – MSMQ ARCHITECTURE WITH DEDICATED DATABASE PROCESSORS

I have a web application in ASP.NET MVC, C # and I have a specific use case that takes a long time to process and users have to wait for the process to complete. I want to use MSMQ and relay most of the work to dedicated processors. Our application has multiple clients and each client has their own SQL database. So suppose 100 clients create 100 separate SQL databases. The real challenge I have is to make the process faster using MSMQ but the task of one client should not affect the performance of others. So I have 2 solutions:

Option 1: Unique MSMQ private queue per database, so in my case it will be 100 queues and this number will increase. 1 dedicated ASP.NET console application that listens to a dedicated MSMQ so in my case it will be 100 processors or console applications.

Option 2: 1 large private MSMQ queue for all databases
A: 1 dedicated processor per database, i.e. 100 processors
Processor B: 1 listening to the big MSMQ

I want to stick with option 1, but would like to know if this is a workable, enterprise type solution?