Пример #1
0
        public ActionResult Create([Bind(Include = "contractTypeid,contract_Type_code,contract_type_name,contract_type_description")] contract_type contract_type)
        {
            if (ModelState.IsValid)
            {
                db.contract_type.Add(contract_type);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(contract_type));
        }
        public ActionResult Create([Bind(Include = "PLAN_ID,TRAINING_PLACE,PERIOD_FROM,PERIOD_TO")] TRAINING_PLAN tRAINING_PLAN)
        {
            if (ModelState.IsValid)
            {
                db.TRAINING_PLAN.Add(tRAINING_PLAN);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tRAINING_PLAN));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "countryid,country_name,country_description")] country country)
        {
            if (ModelState.IsValid)
            {
                db.countries.Add(country);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(country));
        }
Пример #4
0
        public ActionResult Create([Bind(Include = "ID,Name,Description,Non1,Non2,Non3")] MissionType missionType)
        {
            if (ModelState.IsValid)
            {
                db.MissionTypes.Add(missionType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(missionType));
        }
Пример #5
0
        public ActionResult Create([Bind(Include = "fundid,fund_code,resource,Description")] Fund fund)
        {
            if (ModelState.IsValid)
            {
                db.Funds.Add(fund);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(fund));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "ID,RequstingBy,RequestingDate,RequestingUnit,FocalPoint,Purpose,FromDate,ToDate,NumOFP_CO,NumOFP_RB,NumOFP_HQ,NumOFP_Other,Country,GOV,District,OtherPlace,Budget_TR,Number_Roms,Check_inDate,Check_OutDate,Rom_Type,Microphone,HiSpeedInternet,Conf_Call_Device,MMR_Days,BOR_Days,COffeBreak,COffeBreak_UNM,Lunch,Dinner,Coctail_Reception,Dedicated_IT_SUPP,DescripDaysORHours,Transportstion_ForLocal_Staff,Airport_Picup_Services,Other_Services,non1,non2,non3")] requests1 requests1)
        {
            if (ModelState.IsValid)
            {
                db.requests1.Add(requests1);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(requests1));
        }
        public ActionResult Create([Bind(Include = "type_id,type_name,comment,typ01,type02,type22")] TRAINING_TYPE tRAINING_TYPE)
        {
            if (ModelState.IsValid)
            {
                db.TRAINING_TYPE.Add(tRAINING_TYPE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tRAINING_TYPE));
        }
Пример #8
0
        public ActionResult Create([Bind(Include = "functionaltitleid,functional_title_id,functional_title_description_english,functional_title_abreviation_english,functional_title_description_french,functional_title_abreviation_french,functional_title_status,functional_title_created_by,functional_title_created_datetime,functional_title_last_modified_by,functional_title_last_modified_datetime,functional_title_deleted_by,functional_title_deleted_datetime")] functional_title functional_title)
        {
            if (ModelState.IsValid)
            {
                db.functional_title.Add(functional_title);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(functional_title));
        }
Пример #9
0
 public ActionResult Create([Bind(Include = "unitid,unit_id,unit_description_english,unit_abreviation_english,unit_description_french,unit_abreviation_french,unit_status,unit_created_by,unit_created_datetime,unit_last_modified_by,unit_last_modified_datetime,unit_deleted_by,unit_deleted_datetime,unit_short_abreviation,office_id,HOU_ID")] unit unit)
 {
     if (ModelState.IsValid)
     {
         db.units.Add(unit);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.office_id = new SelectList(db.Country_office, "countryofficeid", "office_description_english", unit.office_id);
     ViewBag.HOU_ID    = new SelectList(db.Country_office, "staffid", "staff_email", unit.HOU_ID);
     return(View(unit));
 }
Пример #10
0
        public ActionResult Create([Bind(Include = "sc_id,from_time,to_time,EMP_ID,attend,PLAN_ID,time_open,extra1,extra2,extra3,time_closed,comment")] TRAINING_SC tRAINING_SC)
        {
            if (ModelState.IsValid)
            {
                db.TRAINING_SC.Add(tRAINING_SC);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PLAN_ID = new SelectList(db.TRAINING_PLAN, "PLAN_ID", "TRAINING_PLACE", tRAINING_SC.PLAN_ID);
            return(View(tRAINING_SC));
        }
Пример #11
0
        public ActionResult Create([Bind(Include = "governorates_code,governorates_name,governorates_description,country_code,staff_id")] governorate governorate)
        {
            if (ModelState.IsValid)
            {
                db.governorates.Add(governorate);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.country_code = new SelectList(db.countries, "countryid", "country_name", governorate.country_code);
            return(View(governorate));
        }
Пример #12
0
        public ActionResult Create([Bind(Include = "countryofficeid,office_id,office_description_english,office_abreviation_english,office_description_french,office_abreviation_french,office_status,office_created_by,office_created_datetime,office_last_modified_by,office_last_modified_datetime,office_deleted_by,office_deleted_datetime,country_code")] Country_office country_office)
        {
            if (ModelState.IsValid)
            {
                db.Country_office.Add(country_office);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.country_code = new SelectList(db.countries, "countryid", "country_name", country_office.country_code);
            return(View(country_office));
        }
Пример #13
0
        public ActionResult Create([Bind(Include = "dependentsid,dependents_code,staffid,dependents_first_name,dependents_last_name,dependents_gender,dependents_phone_num,dependents_blood_group,dependents_passport_num,dependents_passport_expiry_date,dependents_notes,dependents_medical_condition")] dependent dependent)
        {
            if (ModelState.IsValid)
            {
                db.dependents.Add(dependent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.staffid = new SelectList(db.staffs, "staffid", "staff_email", dependent.staffid);
            return(View(dependent));
        }
Пример #14
0
        public ActionResult Create([Bind(Include = "Sessionid,CourseID,CourseDuration,CourseStartTime,CourseEndTime,CourseStartDate,CourseEndDate,CourseLocation,SessionName,CoursePrerequisite")] CourseSession courseSession)
        {
            if (ModelState.IsValid)
            {
                db.CourseSessions.Add(courseSession);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "CourseName", courseSession.CourseID);
            return(View(courseSession));
        }
Пример #15
0
        public ActionResult Create([Bind(Include = "TRAINING_ID,TRAINING_NAME,TRAINING_DESC,TRAINING_PLACE,TRAINING_PERIOD,PARENT_TRAINING_ID")] TRAINING tRAINING)
        {
            if (ModelState.IsValid)
            {
                db.TRAININGS.Add(tRAINING);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PARENT_TRAINING_ID = new SelectList(db.TRAININGS, "TRAINING_ID", "TRAINING_NAME", tRAINING.PARENT_TRAINING_ID);
            return(View(tRAINING));
        }
        public ActionResult Create([Bind(Include = "PLAN_ID,TRAINING_ID,REQUIRE_CERTIFICATE,CERTIFICATE_ID,COASTPEREMP,EMPLPERCENTAGE,FAILPASSDEPENDANCY,IFFAILPERCENTAGE,IFPASSPERCENTAGE,TRAINING_TYPE")] TRAINING_PLAN_TRAININGS tRAINING_PLAN_TRAININGS)
        {
            if (ModelState.IsValid)
            {
                db.TRAINING_PLAN_TRAININGS.Add(tRAINING_PLAN_TRAININGS);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PLAN_ID       = new SelectList(db.TRAINING_PLAN, "PLAN_ID", "TRAINING_PLACE", tRAINING_PLAN_TRAININGS.PLAN_ID);
            ViewBag.TRAINING_TYPE = new SelectList(db.TRAINING_TYPE, "type_id", "type_name", tRAINING_PLAN_TRAININGS.TRAINING_TYPE);
            return(View(tRAINING_PLAN_TRAININGS));
        }
Пример #17
0
        public ActionResult Create([Bind(Include = "areacode,area_name,countryid,governorates_code")] district district)
        {
            if (ModelState.IsValid)
            {
                db.districts.Add(district);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.countryid         = new SelectList(db.countries, "countryid", "country_name", district.countryid);
            ViewBag.governorates_code = new SelectList(db.governorates, "governorates_code", "governorates_name", district.governorates_code);
            return(View(district));
        }
Пример #18
0
        public ActionResult Create([Bind(Include = "PLAN_ID,TRAINING_ID,EMP_ID,ATTENDED,PASSED,TRAINING_EVALUATION,TRAINER_EVALUATION,CLASS_ID")] TRAINEE tRAINEE)
        {
            if (ModelState.IsValid)
            {
                db.TRAINEES.Add(tRAINEE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PLAN_ID     = new SelectList(db.TRAINING_PLAN_TRAINING_CLASSES, "PLAN_ID", "CLASS_NAME", tRAINEE.PLAN_ID);
            ViewBag.TRAINING_ID = new SelectList(db.TRAININGS, "TRAINING_ID", "TRAINING_NAME", tRAINEE.TRAINING_ID);
            return(View(tRAINEE));
        }
Пример #19
0
        public ActionResult Create([Bind(Include = "request_no,first_name,last_name,job_title,unit,budget_code,index_number,duty_station,supervisor_email,appointment_type,start_date,end_date,computerLaptop,computerDeskyop,email,access_P,telephone,pincode_ext,local_sim,international,roaming,SmartPhone,BasicPhone,usb_modem,color_printer,BlackberryService,IphoneService,mobile_phone,other,location,requested_by")] request request)
        {
            if (ModelState.IsValid)
            {
                db.requests.Add(request);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.job_title    = new SelectList(db.functional_title, "functionaltitleid", "functional_title_id", request.job_title);
            ViewBag.requested_by = new SelectList(db.staffs, "staffid", "staff_id", request.requested_by);
            ViewBag.requested_by = new SelectList(db.staffs, "staffid", "staff_id", request.requested_by);
            ViewBag.unit         = new SelectList(db.units, "unitid", "unit_id", request.unit);
            return(View(request));
        }
Пример #20
0
        public ActionResult Create([Bind(Include = "ID,MissionID,Description,FromID,FromDate,ToID,ToDate,non1,non2,non3,non4,Fromtime,Totime")] MissionItinerary missionItinerary)
        {
            if (ModelState.IsValid)
            {
                db.MissionItineraries.Add(missionItinerary);
                db.SaveChanges();
                return(RedirectToAction("Index", "MissionAuthorizations"));
            }

            ViewBag.FromID    = new SelectList(db.countries, "countryid", "country_name", missionItinerary.FromID);
            ViewBag.ToID      = new SelectList(db.countries, "countryid", "country_name", missionItinerary.ToID);
            ViewBag.MissionID = new SelectList(db.MissionAuthorizations, "MissionID", "MissionID", missionItinerary.MissionID);
            //return View(missionItinerary);
            return(RedirectToAction("Createitinary", "MissionAuthorizations"));
            //return PartialView("_createiti");
        }
Пример #21
0
        public ActionResult Create([Bind(Include = "contractdetailsid,contract_details_id,contract_details_description_english,contract_details_abreviation_english,contract_details_description_french,contract_details_abreviation_french,contract_details_status,contract_details_created_by,contract_details_created_datetime,contract_details_last_modified_by,contract_details_last_modified_datetime,contract_details_deleted_by,contract_details_deleted_datetime,contract_type_code,fundid,staffid")] contract_details contract_details)
        {
            if (ModelState.IsValid)
            {
                db.contract_details.Add(contract_details);
                db.SaveChanges();


                //staff staffs = new staff()
                //{
                //    stuff_contract_details = contract_details.contractdetailsid,

                //};



                //selectedItem.End_Date = kendo.parseDate(data, "MM/dd/yyyy")
                ////selectedItem.set("End_Date", kendo.parseDate(data, "MM/dd/yyyy"))
                ////db.Entry(staffs).State = EntityState.Modified;
                ////db.staffs.Add(staffs);
                //var res = db.staffs .Include(c => c.staffid );
                var res = (from c in db.staffs
                           where c.staffid == contract_details.staffid
                           select c).SingleOrDefault();


                res.stuff_contract_details = contract_details.contractdetailsid;
                db.SaveChanges();

                return(RedirectToAction("Create"));
            }


            ViewBag.fundid  = new SelectList(db.Funds, "fundid", "resource", contract_details.fundid);
            ViewBag.staffid = new SelectList(db.staffs, "staffid", "staff_email", contract_details.staffid);
            return(View(contract_details));
        }
Пример #22
0
        // GET: /contractdetails/Edit/5
        public ActionResult EditCon(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            contract_details contract_details = db.contract_details.Find(id);

            if (contract_details == null)
            {
                return(HttpNotFound());
            }
            ViewBag.fundid  = new SelectList(db.Funds, "fundid", "resource", contract_details.fundid);
            ViewBag.staffid = new SelectList(db.staffs, "staffid", "staff_email", contract_details.staffid);



            db.SaveChanges();

            return(View(contract_details));
        }
Пример #23
0
        public ActionResult Create([Bind(Include = "request_no,first_name,last_name,job_title,unit,budget_code,index_number,duty_station,supervisor_email,appointment_type,start_date,end_date,computerLaptop,computerDeskyop,email,access_P,telephone,pincode_ext,local_sim,international,roaming,SmartPhone,BasicPhone,usb_modem,color_printer,IphoneService,IphoneService,mobile_phone,other,location,requested_by")] request request)
        {
            if (request.computerDeskyop == false)

            {
                request.computerLaptop = true;
            }



            db.requests.Add(request);

            try
            {
                ///////////////////// staff
                var addunit = db.staffs.Add(new staff {
                    staff_id = request.index_number, staff_first_name = request.first_name, staff_last_name = request.last_name, unit_id = request.unit, staff_supervisorid = request.supervisor_email, functional_title_id = request.job_title, staff_email = request.first_name + "." + request.last_name + "@wfp.org"
                }).staff_index_number;
                db.SaveChanges();
                /////////////////////// staff
                db.SaveChanges();

                var email         = "";
                var PDrive        = "";
                var telephoneext  = "";
                var pincode       = "";
                var localsim      = "";
                var international = "";
                var roaming       = "";
                var USBMODEM      = "";
                var color_printer = "";

                if (request.email == true)
                {
                    email = "Yes";
                }
                else
                {
                    email = "No";
                }

                if (request.access_P == true)
                {
                    PDrive = "Yes";
                }
                else
                {
                    PDrive = "No";
                }

                if (request.telephone == true)
                {
                    telephoneext = "Yes";
                }
                else
                {
                    telephoneext = "No";
                }

                if (request.pincode_ext == true)
                {
                    pincode = "Yes";
                }
                else
                {
                    pincode = "No";
                }

                if (request.local_sim == true)
                {
                    localsim = "Yes";
                }
                else
                {
                    localsim = "No";
                }

                if (request.international == true)
                {
                    international = "Yes";
                }
                else
                {
                    international = "No";
                }

                if (request.roaming == true)
                {
                    roaming = "Yes";
                }
                else
                {
                    roaming = "No";
                }

                if (request.usb_modem == true)
                {
                    USBMODEM = "Yes";
                }
                else
                {
                    USBMODEM = "No";
                }
                if (request.color_printer == true)
                {
                    color_printer = "Yes";
                }
                else
                {
                    color_printer = "No";
                }

                var staffs = db.staffs.Include(s => s.contract_details).Include(s => s.contract_type).Include(s => s.Country_office).Include(s => s.functional_title).Include(s => s.staff2).Include(s => s.sub_office).Include(s => s.unit).Include(s => s.country).Include(s => s.governorate);
                staffs = staffs.Where(s => s.staffid == request.requested_by);
                var requestedby      = staffs.First().staff_first_name + " " + staffs.First().staff_last_name;
                var requestedbyemail = staffs.First().staff_email;

                var title = db.functional_title.Include(s => s.staffs);
                title = title.Where(t => t.functionaltitleid == request.job_title);
                var jobtitle = title.First().functional_title_description_english;

                var unitselect = db.units.Include(s => s.staffs);
                unitselect = unitselect.Where(u => u.unitid == request.unit);
                var unit = unitselect.First().unit_description_english;

                var Superemail = db.staffs.Include(s => s.district);
                Superemail = Superemail.Where(Su => Su.staffid == request.supervisor_email);
                var supervisor_email = Superemail.First().staff_email;



                MailMessage mail = new MailMessage();
                mail.To.Add("*****@*****.**");
                mail.CC.Add(supervisor_email);
                mail.CC.Add("*****@*****.**");

                mail.CC.Add(requestedbyemail);
                //mail.CC.Add("*****@*****.**");
                //mail.CC.Add("*****@*****.**");
                mail.Bcc.Add("*****@*****.**");
                mail.From    = new MailAddress(requestedbyemail);
                mail.Subject = "IT Services Request for :" + request.first_name + " " + request.last_name;

                string Body = "<table border='0'><tr><td colspan='2'><hr/>Request Information<hr/></td><hr/></tr><tr><td><font color='blue'>Request Number: </font></td><td>" + request.request_no + "</td></tr>"
                              + "<tr><td><font color='blue'>" + " Requested By :</font></td><td>" + requestedby + "</td></tr>"
                              + "<tr><td colspan='2'><hr/>PERSONAL INFORMATION<hr/></td></tr>"
                              + "<tr><td><font color='blue'>" + "New Staff :</font></td><td>" + request.first_name
                              + " " + request.last_name + "</td></tr>"
                              + "<tr><td><font color='blue'> JOB TITLE :</font></td><td>" + jobtitle + "</td></tr>"
                              + "<tr><td><font color='blue'>UNIT :</font></td><td>" + unit + "</td></tr>"
                              + "<tr><td><font color='blue'>BUDGET CODE :</font></td><td>" + request.budget_code + "</td></tr>"
                              + "<tr><td><font color='blue'>INDEX NUMBER :</font></td><td>" + request.index_number + "</td></tr>"
                              + "<tr><td><font color='blue'>DUTY STATION :</font></td><td>" + request.duty_station + "</td></tr>"
                              + "<tr><td><font color='blue'>SUPERVISOR EMAIL :</font></td><td>" + supervisor_email + "</td></tr>"
                              + "<tr><td colspan='2'><hr/>Contract Information<hr/></td></tr><tr><td><font color='blue'>Appoinment Type :</font></td><td>" + request.appointment_type + "</td></tr>"
                              + "<tr><td><font color='blue'>START DATE :</font></td><td>" + request.start_date.Value.ToString("dd/MMM/yy") + "</td></tr>"
                              + "<tr><td><font color='blue'>END DATE :</font></td><td>" + request.end_date.Value.ToString("dd/MMM/yy") + "</td></tr>"
                              + "<tr><td colspan='2'><hr/>SERVICES AND EQUIPMENT<hr/></td></tr>" + "<tr><td><font color='blue'>COMPUTER TYPE :</font></td><td>" + request.IphoneService + "</td></tr>"
                              + "<tr><td><font color='blue'>E-MAIL :</font></td><td>" + email + "</td></tr>"
                              + "<tr><td><font color='blue'>ACCESS P DRIVE :</font></td><td>" + PDrive + "</td></tr>"
                              + "<tr><td><font color='blue'>TELEPHONE EXT :</font></td><td>" + telephoneext + "</td></tr>"
                              + "<tr><td><font color='blue'>PINCODE FOR EXTERNAL CALLS :</font></td><td>" + pincode + "</td></tr>"
                              + "<tr><td><font color='blue'>LOCAL MOBILE SIM :</font></td><td>" + localsim + "</td></tr>"
                              + "<tr><td><font color='blue'>INTERNATIONAL :</font></td><td>" + international + "</td></tr>"
                              + "<tr><td><font color='blue'>ROAMING :</font></td><td>" + roaming + "</td></tr>"
                              + "<tr><td><font color='blue'>USB Modem :</font></td><td>" + USBMODEM + "</td></tr>"
                              + "<tr><td><font color='blue'>PHONES :</font></td><td>" + request.mobile_phone + "</td></tr>"
                              + "<tr><td><font color='blue'>COLOR_PRINTER :</font></td><td>" + color_printer + "</td></tr>"
                              + "<tr><td><font color='blue'>OTHER REQUIREMENTS :</font></td><td>" + request.other + "</td></tr>"
                              + "<tr><td><font color='blue'>SITTING LOCATION :</font></td><td>" + request.location + "</td></tr></table>";

                //string Body = "Request : Mission &nbsp;  &nbsp;  &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;  Mission ID : " + missionAuthorization.MissionID + " <br> " + " From &nbsp; &nbsp; &nbsp;:" + staffs.First().staff_first_name + "&nbsp;" + staffs.First().staff_last_name + "<br><br>" + " Mission Information" + "<br><br>" + " From :" + missionAuthorization.FromDate + "<br>To :" + missionAuthorization.ToDate +
                //    "<br>Funding :" + missionAuthorization.funding + "<br>Objective :" + missionAuthorization.MissionObjective + "<br> Mission Itinerary :" + missionAuthorization.MissionItinerary + "<br> Can This meeting Be Done Over Voice/Video ? :" + missionAuthorization.canbedone  + " <br><br> <a href='http://10.11.135.254:8080/WFPSMS/MissionAuthorizations/Approval2?Mid=" + missionAuthorization.MissionID + "&ClearedBySupervisor=" + true + "&FromDate=" + missionAuthorization.FromDate + " &ToDate=" + missionAuthorization.ToDate + " &to=" + to + "&staffmail=" + staffs.First().staff_email + "&supervisorname=" + supername + "'>Acept</a>&nbsp;&nbsp;&nbsp;<a href='http://10.11.135.254:8080/WFPSMS/MissionAuthorizations/Approval?Mid=" + missionAuthorization.MissionID + "&ClearedBySupervisor= " + false + "& FromDate=" + missionAuthorization.FromDate + " &ToDate=" + missionAuthorization.ToDate + "&to=" + to + "&staffmail=" + staffs.First().staff_email + "&supervisorname=" + supername + "'>Reject</a> ";

                mail.Body       = Body;
                mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtprelay.global.wfp.org";
                smtp.Port = 25;
                smtp.UseDefaultCredentials = true;
                //smtp.Credentials = new System.Net.NetworkCredential
                //("ahmed.badr", "Survivor2323");// Enter seders User name and password
                //smtp.EnableSsl = true;
                smtp.Send(mail);

                return(RedirectToAction("Index"));
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.

                var errorMessages = ex.EntityValidationErrors

                                    .SelectMany(x => x.ValidationErrors)

                                    .Select(x => x.ErrorMessage);



                // Join the list to a single string.

                var fullErrorMessage = string.Join("; ", errorMessages);



                // Combine the original exception message with the new one.

                var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);



                // Throw a new DbEntityValidationException with the improved exception message.

                throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
            }

            //MailMessage mail = new MailMessage();
            //mail.To.Add("*****@*****.**");
            //   //mail.CC.Add(cc);
            //   //mail.Bcc.Add("*****@*****.**");
            //   mail.From = new MailAddress("*****@*****.**");
            //   mail.Subject = "IT Services Request for New staff";

            //   string Body = "<br>New Request<br><br> PERSONAL INFORMATION <br><br>  Request Number : " + request.request_no + " <br> " + " From &nbsp; &nbsp; &nbsp;:" + request.requested_by + "<br><br>" + "New Staff :" + request.first_name + " " + request.last_name + "<br> JOB TITLE :" + request.job_title + "<br>UNIT :" + request.unit +
            //           "<br>BUDGET CODE :" + request.budget_code + "<br>INDEX NUMBER :" + request.index_number + "<br> DUTY STATION :" + request.duty_station + "<br> SUPERVISOR EMAIL :" + request.supervisor_email + "<br><br>Contract Information <br><br> Appoinment Type :" + request.appointment_type + "<br> START DATE :" + request.start_date + "<br> END DATE :" + request.end_date + " <br><br>SERVICES AND EQUIPMENT<br>" + "<br>COMPUTER TYPE :" + request.IphoneService + " <br> E-MAIL :" + email + " <br> ACCESS P DRIVE :" + request.access_P + " <br> TELEPHONE EXT :" + request.telephone + "<br> PINCODE FOR EXTERNAL CALLS :" + request.pincode_ext + "<br> LOCAL MOBILE SIM :" + request.local_sim + "<br> INTERNATIONAL :" + request.international + "<br> ROAMING :" + request.roaming + "<br> PHONES :" + request.mobile_phone + "<br> COLOR_PRINTER :" + request.color_printer + "<br> OTHER REQUIREMENTS :" + request.other + "<br> SITTING LOCATION :" + request.location + "<br> REQUESTED BY :" + request.requested_by;

            //   //string Body = "Request : Mission &nbsp;  &nbsp;  &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;  Mission ID : " + missionAuthorization.MissionID + " <br> " + " From &nbsp; &nbsp; &nbsp;:" + staffs.First().staff_first_name + "&nbsp;" + staffs.First().staff_last_name + "<br><br>" + " Mission Information" + "<br><br>" + " From :" + missionAuthorization.FromDate + "<br>To :" + missionAuthorization.ToDate +
            //   //    "<br>Funding :" + missionAuthorization.funding + "<br>Objective :" + missionAuthorization.MissionObjective + "<br> Mission Itinerary :" + missionAuthorization.MissionItinerary + "<br> Can This meeting Be Done Over Voice/Video ? :" + missionAuthorization.canbedone  + " <br><br> <a href='http://10.11.135.254:8080/WFPSMS/MissionAuthorizations/Approval2?Mid=" + missionAuthorization.MissionID + "&ClearedBySupervisor=" + true + "&FromDate=" + missionAuthorization.FromDate + " &ToDate=" + missionAuthorization.ToDate + " &to=" + to + "&staffmail=" + staffs.First().staff_email + "&supervisorname=" + supername + "'>Acept</a>&nbsp;&nbsp;&nbsp;<a href='http://10.11.135.254:8080/WFPSMS/MissionAuthorizations/Approval?Mid=" + missionAuthorization.MissionID + "&ClearedBySupervisor= " + false + "& FromDate=" + missionAuthorization.FromDate + " &ToDate=" + missionAuthorization.ToDate + "&to=" + to + "&staffmail=" + staffs.First().staff_email + "&supervisorname=" + supername + "'>Reject</a> ";

            //   mail.Body = Body;
            //   mail.IsBodyHtml = true;
            //   SmtpClient smtp = new SmtpClient();
            //   smtp.Host = "smtprelay.global.wfp.org";
            //   smtp.Port = 25;
            //   smtp.UseDefaultCredentials = true;
            //   //smtp.Credentials = new System.Net.NetworkCredential
            //   //("ahmed.badr", "Survivor2323");// Enter seders User name and password
            //   //smtp.EnableSsl = true;
            //   smtp.Send(mail);

            //   return RedirectToAction("Index");



            ViewBag.job_title = new SelectList(db.functional_title, "functionaltitleid", "functional_title_description_english", request.job_title);
            //ViewBag.requested_by = new SelectList(db.staffs, "staffid", "staff_id", request.requested_by);
            //ViewBag.requested_by = new SelectList(db.staffs, "staffid", "staff_id", request.requested_by);
            ViewBag.unit             = new SelectList(db.units, "unitid", "unit_description_english", request.unit);
            ViewBag.supervisor_email = new SelectList(db.staffs.OrderBy(staffs => staffs.staff_email), "staffid", "staff_email", request.supervisor_email);
            return(View(request));
        }
        public ActionResult Create(Models.MailModel objModelMail, [Bind(Include = "MissionID,staffid,FromDate,ToDate,MissionItinerary,funding,ClearedBySupervisor,MissionObjective,ExpectedOutputs,FollowUp,SignatureDate")] MissionAuthorization missionAuthorization)
        {
            if (ModelState.IsValid)
            {
                db.MissionAuthorizations.Add(missionAuthorization);
                try

                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)

                {
                    // Retrieve the error messages as a list of strings.

                    var errorMessages = ex.EntityValidationErrors

                                        .SelectMany(x => x.ValidationErrors)

                                        .Select(x => x.ErrorMessage);



                    // Join the list to a single string.

                    var fullErrorMessage = string.Join("; ", errorMessages);



                    // Combine the original exception message with the new one.

                    var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);



                    // Throw a new DbEntityValidationException with the improved exception message.

                    throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
                }
                var staffs = db.staffs.Include(s => s.contract_details).Include(s => s.contract_type).Include(s => s.Country_office).Include(s => s.functional_title).Include(s => s.staff2).Include(s => s.sub_office).Include(s => s.unit).Include(s => s.country).Include(s => s.governorate);
                staffs = staffs.Where(s => s.staff_email.Contains(User.Identity.Name + "@wfp.org"));

                //ViewBag.staffid = new SelectList(db.staffs, "staffs.First().staffid", staffs.First().staff_email);
                ViewBag.staffid   = staffs.First().staffid;
                ViewBag.staffid2  = staffs.First().staff_first_name;
                ViewBag.FirstName = staffs.First().staff_first_name;
                ViewBag.LastName  = staffs.First().staff_last_name;
                ViewBag.Unit      = staffs.First().unit.unit_description_english;
                var staffsupervisor = staffs.First().staff_supervisorid;

                var supers = db.staffs.Include(d => d.contract_details).Include(d => d.contract_type).Include(d => d.Country_office).Include(d => d.functional_title).Include(d => d.staff2).Include(d => d.sub_office).Include(d => d.unit).Include(d => d.country).Include(d => d.governorate);
                supers = supers.Where(d => d.staffid == staffsupervisor);


                var to = supers.First().staff_email;


                MailMessage mail = new MailMessage();
                mail.To.Add(to);
                mail.From    = new MailAddress("*****@*****.**");
                mail.Subject = "Mission Authorization Form";
                string Body = "Request : Mission &nbsp;  &nbsp;  &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;  Mission ID : " + missionAuthorization.MissionID + " <br> " + " From &nbsp; &nbsp; &nbsp;:" + staffs.First().staff_first_name + "&nbsp;" + staffs.First().staff_last_name + "<br><br>" + " Mission Information" + "<br><br>" + " From :" + missionAuthorization.FromDate + "&nbsp; &nbsp; &nbsp; &nbsp; To :" + missionAuthorization.ToDate +
                              "<br>Funding :" + missionAuthorization.funding + "&nbsp;  &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;" + "Objective :" + missionAuthorization.MissionObjective;
                mail.Body       = Body;
                mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtprelay.global.wfp.org";
                smtp.Port = 25;
                smtp.UseDefaultCredentials = true;
                //smtp.Credentials = new System.Net.NetworkCredential
                //("ahmed.badr", "Survivor2323");// Enter seders User name and password
                //smtp.EnableSsl = true;
                smtp.Send(mail);


                //string from = "*****@*****.**";
                ////Replace this with your own correct Gmail Address

                //string to = "*****@*****.**";
                ////Replace this with the Email Address
                ////to whom you want to send the mail

                //System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                //mail.To.Add(to);
                //mail.From = new MailAddress(from);
                //mail.Subject = "This is a test mail";
                //mail.SubjectEncoding = System.Text.Encoding.UTF8;
                //mail.Body = "This is Email Body Text";
                //mail.BodyEncoding = System.Text.Encoding.UTF8;
                //mail.IsBodyHtml = true;
                //mail.Priority = MailPriority.High;

                //SmtpClient client = new SmtpClient("smtp.WFPEGSIMSP01.global.wfp.org", 25);

                ////Add the Creddentials- use your own email id and password
                //System.Net.NetworkCredential nt =
                //new System.Net.NetworkCredential("ahmed.badr", "Survivor2323");

                //client.Port = 25; // Gmail works on this port
                //client.EnableSsl = false; //Gmail works on Server Secured Layer
                //client.UseDefaultCredentials = true;
                //client.Credentials = nt;
                //client.Send(mail);


                //    var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                //    var message = new MailMessage();
                //    message.To.Add(new MailAddress("*****@*****.**"));  // replace with valid value
                //    message.From = new MailAddress("*****@*****.**");  // replace with valid value
                //    message.Subject = "Your email subject";
                //    message.Body = string.Format(body,"hhh","hjkjh","kjlkjl");
                //    message.IsBodyHtml = true;

                //    using (var smtp = new SmtpClient())
                //    {
                //        var credential = new NetworkCredential
                //        {
                //            UserName = "******",  // replace with valid value
                //            Password = "******"  // replace with valid value
                //        };
                //        smtp.Credentials = credential;
                //        smtp.Host = "smtprelay.global.wfp.org";
                //        smtp.Port = 25;
                //        smtp.EnableSsl = true;
                //        smtp.SendMailAsync(message);


                return(RedirectToAction("Index"));


                //    }

                //}
            }

            //ViewBag.staffid = User.Identity.GetUserName() + "@wfp.org";
            return(RedirectToAction("Create"));
        }