public string Submit(string Customer_id, string UserName) { try { List <Customer_Order> submitionList = Data.Customer_Order.Where(x => x.Purches_id == Customer_id && x.Order_Status == 1).ToList(); int Total = 0; System.Random rand = new System.Random((int)System.DateTime.Now.Ticks); int random = rand.Next(1, 100000000); string Path = @"D:\Repositories\HatBazar\Email_Document\Customer_Order\" + random + ".txt"; //Pass the filepath and filename to the StreamWriter Constructor //StreamWriter sw = new StreamWriter(@"D:\Repositories\HatBazar\Email_Document\Admin_Email\Document.txt"); StreamWriter sw = new StreamWriter(Path); //Write a line of text sw.WriteLine(System.IO.File.ReadAllText(@"D:\Repositories\HatBazar\Email_Document\Customer_Order\Order1.txt")); sw.WriteLine("Date :" + DateTime.Now); //*************************************************** foreach (var i in submitionList) { if (i.Unit_name == "PACKAGE") { int packageid = (i.Product_id).Value; List <Package_With_Product> Item = Data.Package_With_Product.Where(x => x.Package_Id == packageid).ToList(); foreach (var product in Item) { Product_Stock CO = Data.Product_Stock.Single(Z => Z.Product_id == product.Product_Id); int J = Int32.Parse(CO.Stock_unit); J = J - product.Unit_Number; CO.Stock_unit = J.ToString(); Data.Entry(CO).State = EntityState.Modified; bool Check = Data.Order_For_Shop.Any(x => x.Product_Name == (product.Product_Name)); if (Check == true) { Order_For_Shop order = Data.Order_For_Shop.Single(Z => Z.Product_Name == product.Product_Name); order.Unit_Number = product.Unit_Number + (order.Unit_Number); var price = Data.Product_Information.Single(x => x.Product_id == order.Product_Id); order.Total_Price = (order.Unit_Number) * (price.Price_per_unit); Data.Entry(order).State = EntityState.Modified; Product_SellingDate psd = new Product_SellingDate(); psd.Product_Id = order.Product_Id; psd.Product_Name = order.Product_Name; psd.Unit_Number = product.Unit_Number; psd.Unit_Name = order.Unit_Name; psd.Price = i.Price * product.Unit_Number; psd.Selected = 0; var dateTimeNow = DateTime.Now; // Return 00/00/0000 00:00:00 psd.Date = dateTimeNow.ToShortDateString(); Data.Product_SellingDate.Add(psd); Data.SaveChanges(); } else { Order_For_Shop OF = new Order_For_Shop(); OF.Product_Name = product.Product_Name; OF.Unit_Name = product.Unit_Name; OF.Unit_Number = product.Unit_Number; var price = Data.Product_Information.Single(x => x.Product_id == OF.Product_Id); OF.Total_Price = price.Price_per_unit; Data.Order_For_Shop.Add(OF); Product_SellingDate psd = new Product_SellingDate(); psd.Product_Id = OF.Product_Id; psd.Product_Name = product.Product_Name; psd.Unit_Number = product.Unit_Number; psd.Unit_Name = product.Unit_Name; psd.Price = i.Price * product.Unit_Number; psd.Selected = 0; var dateTimeNow = DateTime.Now; // Return 00/00/0000 00:00:00 psd.Date = dateTimeNow.ToShortDateString(); Data.Product_SellingDate.Add(psd); Data.SaveChanges(); } } } else { Product_Stock CO = Data.Product_Stock.Single(Z => Z.Product_id == (i.Product_id).Value); int J = Int32.Parse(CO.Stock_unit); J = J - (i.Unit_number).Value; CO.Stock_unit = J.ToString(); Data.Entry(CO).State = EntityState.Modified; bool Check = Data.Order_For_Shop.Any(x => x.Product_Name == (i.Product_Name)); if (Check == true) { Order_For_Shop order = Data.Order_For_Shop.Single(Z => Z.Product_Name == i.Product_Name); order.Unit_Number = (i.Unit_number).Value + (order.Unit_Number); var price = Data.Product_Information.Single(x => x.Product_name == order.Product_Name); // var price = Data.Product_Information.Single(x => x.Product_id == order.Product_Id); order.Total_Price = (order.Unit_Number) * (price.Price_per_unit); Data.Entry(order).State = EntityState.Modified; Product_SellingDate psd = new Product_SellingDate(); psd.Product_Id = order.Product_Id; psd.Product_Id = order.Product_Id; psd.Product_Name = order.Product_Name; psd.Unit_Number = i.Unit_number; psd.Unit_Name = order.Unit_Name; psd.Price = price.Price_per_unit * i.Unit_number; psd.Selected = 0; var dateTimeNow = DateTime.Now; // Return 00/00/0000 00:00:00 psd.Date = dateTimeNow.ToShortDateString(); Data.Product_SellingDate.Add(psd); Data.SaveChanges(); } else { Order_For_Shop OF = new Order_For_Shop(); //OF.Product_Id = (i.Product_id).Value; OF.Product_Name = i.Product_Name; OF.Unit_Name = i.Unit_name; OF.Unit_Number = (i.Unit_number).Value; Data.Order_For_Shop.Add(OF); Product_SellingDate psd = new Product_SellingDate(); psd.Product_Id = (i.Product_id).Value; psd.Product_Name = i.Product_Name; psd.Unit_Number = i.Unit_number; psd.Unit_Name = i.Unit_name; psd.Price = i.Price * i.Unit_number; psd.Selected = 0; var dateTimeNow = DateTime.Now; // Return 00/00/0000 00:00:00 psd.Date = dateTimeNow.ToShortDateString(); Data.Product_SellingDate.Add(psd); Data.SaveChanges(); } } i.Order_Status = 0; var date = DateTime.Now; i.Date = date.ToShortDateString(); Data.Entry(i).State = EntityState.Modified; //*********************************** try { string Information = "Product Name :" + i.Product_Name + "Unit :" + i.Unit_number + "" + i.Unit_name + "Price:" + (i.Unit_number * i.Price); sw.WriteLine(Information); Total = Total + (i.Unit_number * i.Price).Value; } catch { return("Path Missing to save Email."); } //*********************************** } Order_with_Date OD = new Order_with_Date(); var date2 = DateTime.Now; OD.Date = date2.ToShortDateString(); OD.User_Name = UserName; OD.Total_Price = Total; Data.Order_with_Date.Add(OD); Data.SaveChanges(); sw.WriteLine("Total : " + Total); sw.WriteLine(System.IO.File.ReadAllText(@"D:\Repositories\HatBazar\Email_Document\Customer_Order\Order2.txt")); sw.Close(); IEmail_Service email = new Email_ServiceClass(); int ia = Int32.Parse(Customer_id); Customer_Information Info = Data.Customer_Information.Single(x => x.Customer_id == ia); Email_Service_Model obj = new Email_Service_Model(); obj.ToEmail = Info.Email; obj.EmailSubject = "Hat Bazar"; obj.EMailBody = System.IO.File.ReadAllText(Path); return(email.SendEmail(obj)); } catch { return("Submission Failure"); } }
public string Create(JobApplication myform) { try { Job_Application apply = new Job_Application(); System.Random rand = new System.Random((int)System.DateTime.Now.Ticks); int random = rand.Next(1, 100000000); apply.Application_id = random.ToString(); // Auto generate hobe apply.First_name = myform.First_name; apply.Last_name = myform.Last_name; apply.Address = myform.Address; apply.Phone = myform.Phone; apply.Email = myform.Email; apply.Gender = myform.Gender; apply.DateOfBirth = myform.Date + "-" + myform.Month + "-" + myform.BirthYear; apply.Marrage_status = myform.Marrage_status; apply.Last_degree = myform.Last_degree; apply.Year = myform.Year; apply.Subject = myform.Subject; apply.Post = myform.Post; apply.About = myform.About; Data.Job_Application.Add(apply); Data.SaveChanges(); //ModelState.Clear(); try { System.Random rand1 = new System.Random((int)System.DateTime.Now.Ticks); int random1 = rand1.Next(1, 100000000); string Path = @"D:\Repositories\HatBazar\Email_Document\Job_Application\" + random1 + ".txt"; StreamWriter sw = new StreamWriter(Path); //Write a line of text sw.WriteLine(System.IO.File.ReadAllText(@"D:\Repositories\HatBazar\Email_Document\Job_Application\Document1.txt")); sw.WriteLine("Application ID :" + apply.Application_id); sw.WriteLine("First Name :" + apply.First_name); sw.WriteLine("Last Name :" + apply.Last_name); sw.WriteLine("Address :" + apply.Address); sw.WriteLine("Phone Number :" + apply.Phone); sw.WriteLine("Email :" + apply.Email); sw.WriteLine("Gender :" + apply.Gender); sw.WriteLine("Date of Birth :" + apply.DateOfBirth); sw.WriteLine("Maritarial Status :" + apply.Marrage_status); sw.WriteLine("Latest Degree :" + apply.Last_degree); sw.WriteLine("Year of Passing :" + apply.Year); sw.WriteLine("Subject :" + apply.Subject); sw.WriteLine("Post :" + apply.Post); sw.WriteLine("Resume :" + apply.About); //sw.WriteLine("all Togather :" + apply); sw.WriteLine(System.IO.File.ReadAllText(@"D:\Repositories\HatBazar\Email_Document\Job_Application\Document2.txt")); sw.Close(); try { //Email_ServiceController Email = new Email_ServiceController(); IEmail_Service Email = new Email_ServiceClass(); Email_Service_Model obj = new Email_Service_Model(); obj.ToEmail = apply.Email; obj.EmailSubject = "Hat Bazar"; obj.EMailBody = System.IO.File.ReadAllText(Path); return(Email.SendEmail(obj)); } catch (Exception) { return("Problem while sending email, Please check details."); } } catch { return("Path Missing ."); } } catch { return("Path Missing to save Email."); } }
public string Complain(Complain complain) { Customer_Complain CC = new Customer_Complain(); try { Customer_Information C = Data.Customer_Information.First(x => x.User_id == complain.User_Name); CC.Customer_ID = C.Customer_id; CC.DateTime = DateTime.Now; CC.Massage = complain.Message; Data.Customer_Complain.Add(CC); Data.SaveChanges(); //ModelState.Clear(); //TempData["Message"] = "Complain Submitted."; try { System.Random rand = new System.Random((int)System.DateTime.Now.Ticks); int random = rand.Next(1, 100000000); string Path = @"D:\Repositories\HatBazar\Email_Document\Admin_Email\" + random + ".txt"; //Pass the filepath and filename to the StreamWriter Constructor //StreamWriter sw = new StreamWriter(@"D:\Repositories\HatBazar\Email_Document\Admin_Email\Document.txt"); StreamWriter sw = new StreamWriter(Path); //Write a line of text sw.WriteLine(System.IO.File.ReadAllText(@"D:\Repositories\HatBazar\Email_Document\Admin_Email\Admin1.txt")); sw.WriteLine(complain.Message); sw.WriteLine(System.IO.File.ReadAllText(@"D:\Repositories\HatBazar\Email_Document\Admin_Email\Admin2.txt")); //Write a second line of text //sw.WriteLine("From the StreamWriter class"); //Close the file sw.Close(); try { //Email_ServiceController Email = new Email_ServiceController(); IEmail_Service Email = new Email_ServiceClass(); Email_Service_Model obj = new Email_Service_Model(); obj.ToEmail = C.Email; obj.EmailSubject = "Hat Bazar"; obj.EMailBody = System.IO.File.ReadAllText(Path); return(Email.SendEmail(obj)); } catch (Exception) { return("Problem while sending email, Please check details."); } } catch { return("Path Missing to save Email."); } } catch { //ModelState.Clear(); return("Invalid User Name."); } }