コード例 #1
0
        public ActionResult Create(Mandate pc)
        {
            float diffdays  = (float)((pc.end_Date.Date - pc.start_Date.Date).Days);
            float costfloat = 1F;

            if (diffdays < 60F)
            {
                costfloat = diffdays * 5F;
            }
            else if (diffdays > 60F)
            {
                costfloat = diffdays * 7.5F;
            }
            pc.Fees = costfloat;

            Person p1 = new Person();
            IEnumerable <Person> list = rs.GetAll();

            foreach (Person p in list)
            {
                if (p.Id.Equals(pc.Id))
                {
                    p1 = p;
                }
            }

            try
            {
                MailMessage message = new MailMessage("*****@*****.**", p1.Email, "You Are Assigned To an other mandate", "Hello Mr Ressource you are assigned to work for an other Project . Greeting LeviO ");
                message.IsBodyHtml = true;
                SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                client.EnableSsl   = true;
                client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "18071964dad");
                client.Send(message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }


            gm.createMandat(pc);
            gm.Commit();

            return(RedirectToAction("Index", "Mandate"));
        }