Git Product home page Git Product logo

mailbox's Introduction

Mail-Scheduling

Full stack application built using ASP.NET Core, EF Core, SSMS and Angular. This lets the user schedule an Mail and Perform CRUD on it.

  • Click ⭐if you like the project. Pull Request are highly appreciated.

Running guide

Download the zip. Open Mail.sln and run IIS Express.

Project description :

Mail scheduling lets Admin(For now) to schedule the Mail for a particular date and time. The admin can later update and delete the Mail on demand.

Patterns used:

  • Dependency Injection Pattern
  • Singleton pattern
  • PUBSUB Pattern

Angular features:

  • Reactive forms
  • Components
  • services
  • Pipes
  • Angular routing
  • Dependency Injection
  • Observables from rxjs

Documentation:

Client Side using Angular.

Following is the customer model.

    
export interface customerModel {
  MailDate: string;
  MailID: number;
  dateOfBirth: string;
  firstName: string;
  lastName: string;
}
  • Reactive form for the customer details. Createthe following form in the ngoninit.
 this.customerForm = this.fb.group({
      FirstName: ['', [Validators.required, Validators.minLength(2), Validators.maxLength(50)]],
      LastName: ['', [Validators.required, Validators.minLength(2), Validators.maxLength(50)]],
      DateOfBirth: [''],
      MailTime: ['']
    });
  • Service is created to make the calls to the API which returns an observable which can be subscribed to when needed.
@Injectable()
export class HomeService {

  constructor(private http: HttpClient) { }


  CreateMail(data: string): Observable<any> {
    return this.http.post("https://localhost:44396/api/SampleData/CreateMail", data);
  }


  GetMail(MailId: any): Observable<any> {
    return this.http.get("https://localhost:44396/api/SampleData/" + MailId );
  }

  UpdateMail(data: string): Observable<any> {
    return this.http.post("https://localhost:44396/api/SampleData/UpdateTodoItem", data);
  }


  DeleteMail(data: string): Observable<any> {
    console.log("reached delete Mail");
    return this.http.post("https://localhost:44396/api/SampleData/DeleteMail", data);
  }
  }
  • Subscribing to the service in the type script file: When the service is created, it can be injected into the component using dependency injection. Which can be subsrcbed by using .subsrcibe method by using PUBSUB pattern .
 onSubmit(): void {
  console.log(this.customerForm.value);
  var data = this.customerForm.value;
  this.homeService.CreateMail(data).subscribe(
    result => {
      console.log(result);
    }
  )
  • Similarly, code can be found inside the ClientApp folder for deleting and updating the Mails.

Web API using .NET core, EF core, C#, LINQ:

 [HttpPost("[action]")]
     public async Task<ActionResult<int>> CreateMail([FromBody] Entities.Mail item)
     {
         try
         {
             _context.Mails.Add(item);
             var result = await _context.SaveChangesAsync();

             //Sending email

             var message = new MimeMessage();
             //From Address
             message.From.Add(new MailboxAddress("sai vaibhav medavarapu", "[email protected]"));

             //To address
             message.To.Add(new MailboxAddress("S Medavarapu", "[email protected]"));
             //Subject
             message.Subject = "Mail confirmed";
             //Body
             message.Body = new TextPart("plain")
             {
                 Text = "Mail confirmed"
             };


             //Configure and send the email

             using (var client = new SmtpClient())
             {
                 // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS)
                 client.ServerCertificateValidationCallback = (s, c, h, e) => true;

                 client.Connect("smtp.gmail.com", 587, false);

                 // Note: only needed if the SMTP server requires authentication
                 client.Authenticate("Your Username", "your password");

                 client.Send(message);
                 client.Disconnect(true);
             }
             return item.MailID;
         }
         catch (Exception ex)
         {

         }
         return null;
     }

For delete operation

     public async Task<ActionResult<Entities.Mail>> DeleteMail([FromBody]Entities.Mail item)
     {
         try
         {

             var student = await _context.Mails.FirstOrDefaultAsync(b => b.MailID == item.MailID);
             _context.Mails.Remove(student);
             await _context.SaveChangesAsync();
             return NoContent();
         }
         catch (Exception ex)
         {

         }
         return null;
     }
 ```

mailbox's People

Contributors

saimedavarapu avatar ilij4 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.