public int AddCustomer(string name, string surname, string email)
        {
            ICustomer newCustomer = factory.CreateCustomer(name, surname, email);
            int       custID      = customerRepository.AddCustomer(newCustomer);

            Debug.WriteLine("Customer with ID " + custID + " added to repo from facade");
            string content = "Congratulations on becoming one of our customers. We hope" +
                             "you will be satisfied with our service.";

            mailSender.SendMail(email, content);
            return(custID);
        }
        public int GenerateWorkseet(int employeeID, int hoursWorked, decimal hourlyRate)
        {
            Debug.WriteLine("Looking for employee with id " + employeeID + " in repo from facade");
            IEmployee employee = employeeRepository.GetEmployee(employeeID);

            if (employee == null)
            {
                Console.WriteLine("Employee with entered ID not found");
                return(-1);
            }
            IWorkSheet worksheet = factory.CreateWorkSheet(employee, DateTime.Today, hourlyRate, hoursWorked);
            int        id        = workSheetRepository.AddWorkSheet(worksheet);
            string     content   = "Worksheet successfully submited on date " + worksheet.WorkSheetDate;

            mailSender.SendMail(worksheet.employee.Email, content);
            Debug.WriteLine("Worksheet with ID " + id + " added to repo from facade");
            return(id);
        }
        public int AddPart(int supplierID, string partNumber, string manufacturer)
        {
            Debug.WriteLine("Looking for supplier with id " + supplierID + " in repo from facade");
            ISupplier supplier = supplierRepository.GetSupplier(supplierID);

            if (supplier == null)
            {
                Console.WriteLine("Supplier with entered ID not found");
                return(-1);
            }
            IPart  part    = factory.CreatePart(partNumber, manufacturer, supplier);
            int    id      = partRepository.AddPart(part);
            string content = "We would like to place an order for part " + part.PartNumber +
                             " manufacturer " + part.Manufacturer;

            mailSender.SendMail(supplier.Email, content);
            Debug.WriteLine("Part with ID " + id + " added to repo from facade");
            return(id);
        }
Exemple #4
0
        //this method submits applicants form to the database and notifies the Admin that posted the job.
        public string SubmitApplication(ApplicationFormViewModel applicationForm, string NameLetter
                                        , string userid, string NameCV)
        {
            string result = "";

            try
            {
                Applications newApplications = new Applications()
                {
                    FirstName   = applicationForm.FirstName,
                    OtherNames  = applicationForm.OtherNames,
                    LastName    = applicationForm.LastName,
                    Address     = applicationForm.Address,
                    Phonenumber = applicationForm.Phonenumber,
                    State       = applicationForm.State,
                    JobID       = applicationForm.JobID,
                    UserId      = userid,
                    Email       = applicationForm.Email,
                    NameCV      = NameCV,
                    NameLetter  = NameLetter,
                    CV          = JobApplicationServices.ConvertToByte(applicationForm.CV),
                    Letter      = JobApplicationServices.ConvertToByte(applicationForm.Letter),
                    DateCreated = DateTime.Now,
                };

                string HTMLcontent = "This is to inform you that <b>" + applicationForm.FirstName
                                     + " " + applicationForm.LastName + "</b> Has applied for the job offer you posted on JB Limited";

                var res = isendMail.SendMail(
                    "*****@*****.**",
                    iadmin.GetAdminEmail(applicationForm.JobID),
                    "NEW APPLICANT",
                    HTMLcontent
                    );
                if (res.IsCompleted)
                {
                    dbContext.applications.Add(newApplications);
                    dbContext.SaveChanges();
                    result = "Success";
                }
                else
                {
                    result = "An internal Error Occured. Please check you Network";
                }
            }
            catch (Exception e)
            {
                result = "Error: " + e.Message;
            }
            return(result);
        }