protected void UserSelect_Click(object sender, EventArgs e) { UserMode.Text = string.Empty; UserMode.Text = "EditUser"; //Disable New User Button NewUserbtn.Enabled = false; NewUserbtn.Visible = false; EditUserbtn.Enabled = false; //Fill in form try { using (var PCTModel = new PCTEntities()) { var selectedUser = (from ua in PCTModel.userAccounts join u in PCTModel.employees on ua.emp_id equals u.ID where ua.ID.ToString() == UserDropDown.SelectedValue select ua).First(); fname_txt.Text = selectedUser.first_name; lname_txt.Text = selectedUser.last_name; username_txt.Text = selectedUser.email; empStat_dropdownlist.SelectedValue = selectedUser.employee.empStatus_id.ToString(); dept_dropdownlist.SelectedValue = selectedUser.employee.dept_id.ToString(); String status = selectedUser.accountStatus.ToString(); if (status == "True") { acct_dropdownlist.SelectedValue = "1"; } else { acct_dropdownlist.SelectedValue = "0"; } RoleDropDownList.SelectedValue = selectedUser.userRole_id.ToString(); //var selectedUserEmp = (from ue in PCTModel.employees // where ue.ID.ToString() == UserDropDown.SelectedValue // select ue).First(); //Need to parse the DATETIME for hiredate string str = selectedUser.employee.hireDate.ToString(); string[] HireDateArray = null; char[] splitchar = { ' ' }; HireDateArray = str.Split(splitchar); hireDate.Text = HireDateArray[0]; } } catch (Exception ex) { throw ex; } //Show Panel that contains the form GeneralPanel.Visible = true; }
private void updateGoogleEvent(CalendarService service2, string EventID, GridViewCommandEventArgs cmdArgs) { string fullname; try { //join the request id and join on userAccount id to update the Summary to Approved or Denied using (var Googlecontext = new PCTEntities()) { var userEvent = (from ev in Googlecontext.requests join u in Googlecontext.userAccounts on ev.userAccount_id equals u.ID where ev.ID.ToString() == EventID select ev).First(); if (cmdArgs.CommandName == "Approve") { //change google calendars summary fullname = (userEvent.userAccount.first_name + " " + userEvent.userAccount.last_name + " Off - Approved"); } if (cmdArgs.CommandName == "Deny") { //delete event from google calendar service2.Events.Delete("*****@*****.**", EventID).Execute(); } } } catch (Exception ex) { throw ex; } }
private bool NewMethod(string usernameTxt, string passwordTxt) { try { using (var ModelPCT = new PCTEntities()) { var username = (from c in ModelPCT.userAccounts where c.email == usernameTxt select c).First(); //Test with hashedPassword which is a string for my test account var password = (from p in ModelPCT.userAccounts where p.hashedPassword == passwordTxt select p).First(); string user = username.ID.ToString(); //if username and password returns 1 then authorize to go to their home page if (username.email != null && password.hashedPassword != null) { //create session Session["USER"] = user; Response.Redirect("Default.aspx"); } else { Login1.FailureText = "No user found!"; } } return(true); } catch { return(false); } }
private void updateRequest(string ID, GridViewCommandEventArgs args) { //might just want to insert this in other method. try { using (var RequestEntity = new PCTEntities()) { var request = (from r in RequestEntity.requests where r.ID.ToString() == ID select r).FirstOrDefault(); if (args.CommandName == "Approve") { request.status = "Approved"; } if (args.CommandName == "Deny") { request.status = "Denied"; } } } catch (Exception ex) { throw ex; } }
}; // Manage your calendars protected void Page_Load(object sender, EventArgs e) { if (Session["USER"] == null) { Response.Redirect("Login.aspx"); } //current_user = user id current_user = Session["USER"].ToString(); bool deptManager; try { using (var deptModel = new PCTEntities()) { var User = (from u in deptModel.userAccounts join emp in deptModel.employees on u.emp_id equals emp.ID where u.ID.ToString() == current_user select u).FirstOrDefault(); //employee is dept manager deptManager = Convert.ToBoolean(User.employee.IsDeptManager); //verify the user is authenticated if (deptManager == true) { deptDropDownList.SelectedValue = User.employee.dept_id.ToString(); } else { Response.Redirect("Login.aspx"); } } } catch (Exception ex) { throw ex; } var certificate = new X509Certificate2(@"C:\Users\glinn\Source\Repos\TestProject\TestProject\SeniorProject-ee5b3ab2ec84.p12", "notasecret", X509KeyStorageFlags.Exportable); var serviceAccountEmail = "*****@*****.**"; ServiceAccountCredential credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { Scopes = scopes }.FromCertificate(certificate)); // Create the service. service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "SeniorProject", }); }
//Selects an employee to create a new user for protected void EmployeeSelect_Click(object sender, EventArgs e) { UserMode.Text = string.Empty; UserMode.Text = "NewUser"; //Disable Edit User Button EditUserbtn.Enabled = false; EditUserbtn.Visible = false; NewUserbtn.Enabled = false; PasswordLabel.InnerText = "Password*:"; confirmPass_label.InnerText = "Confirm Password*:"; // hireDate.Value = //fill in form try { using (var PCTModel = new PCTEntities()) { var selectedEmployee = (from c in PCTModel.employees where c.ID.ToString() == EmployeeDropDown.SelectedValue select c).First(); fname_txt.Text = selectedEmployee.first_name; lname_txt.Text = selectedEmployee.last_name; username_txt.Text = selectedEmployee.email; empStat_dropdownlist.SelectedValue = selectedEmployee.empStatus_id.ToString(); dept_dropdownlist.SelectedValue = selectedEmployee.dept_id.ToString(); //Need to parse the DATETIME for hiredate string str = selectedEmployee.hireDate.ToString(); string[] HireDateArray = null; char[] splitchar = { ' ' }; HireDateArray = str.Split(splitchar); hireDate.Text = HireDateArray[0]; } } catch (Exception ex) { throw ex; } //Show Panel that contains the form GeneralPanel.Visible = true; }
protected void SubmitBtn_Click(object sender, EventArgs e) { userAccount userEnt = new userAccount(); PasswordRFV.Enabled = true; confirmPassRFV.Enabled = true; try { //if user is creating a new user if (UserMode.Text == "NewUser") { // using (var PCTModel = new PCTEntities()) { //post int fullday; int lunchBreak; using (var context = new PCTEntities()) { userEnt.first_name = fname_txt.Text; userEnt.last_name = lname_txt.Text; userEnt.email = username_txt.Text; userEnt.dateCreated = DateTime.Now; userEnt.createdBy = current_user; userEnt.emp_id = Convert.ToInt32(EmployeeDropDown.SelectedValue); userEnt.userRole_id = Convert.ToInt32(RoleDropDownList.SelectedValue); if (empStat_dropdownlist.SelectedItem.ToString() == "Full-Time") { fullday = 8; lunchBreak = 60; } else if (empStat_dropdownlist.SelectedItem.ToString() == "Part-Time") { fullday = 4; lunchBreak = 15; } else { fullday = 0; lunchBreak = 0; } userEnt.fullDayHours = fullday; userEnt.lunch = lunchBreak; //BAD PRACTICE userEnt.hashedPassword = NewPassword.Value.ToString(); //account status, and user role int accountStat = Convert.ToInt16(acct_dropdownlist.SelectedValue); userEnt.accountStatus = Convert.ToBoolean(accountStat); //------------------create a hashed password----------------------- //string password = NewPassword.Value.ToString(); // // Run the functions on the code, // string hashed = Crypto.Hash(password, "MD5"); // string sha256 = Crypto.SHA256(password); // string sha1 = Crypto.SHA1(password); //string salt = Crypto.GenerateSalt(); // hashedPassword = Crypto.HashPassword(password); // // First parameter is the previously hashed string using a Salt // verify = Crypto.VerifyHashedPassword("{hash_password_here}", password); //} context.userAccounts.Add(userEnt); context.SaveChanges(); } } } if (UserMode.Text == "EditUser") { PasswordRFV.Enabled = false; confirmPassRFV.Enabled = false; using (var editUserSub = new PCTEntities()) { var User = (from ua in editUserSub.userAccounts where ua.ID.ToString() == UserDropDown.SelectedValue select ua).First(); User.first_name = fname_txt.Text; User.last_name = lname_txt.Text; User.email = username_txt.Text; User.lastUpdated = DateTime.Now; User.userRole_id = Convert.ToInt32(RoleDropDownList.SelectedValue); int accountStat = Convert.ToInt16(acct_dropdownlist.SelectedValue); User.accountStatus = Convert.ToBoolean(accountStat); //BAD PRACTICE bool np = string.IsNullOrEmpty(NewPassword.Value.ToString()); bool cp = string.IsNullOrEmpty(confirmPass_txt.Text); if (np == false && cp == false) { User.hashedPassword = NewPassword.Value.ToString(); } //account status, and user role int accountStatus2 = Convert.ToInt16(acct_dropdownlist.SelectedValue); userEnt.accountStatus = Convert.ToBoolean(accountStatus2); //------------------create a hashed password----------------------- //string password = NewPassword.Value.ToString(); // // Run the functions on the code, // string hashed = Crypto.Hash(password, "MD5"); // string sha256 = Crypto.SHA256(password); // string sha1 = Crypto.SHA1(password); //string salt = Crypto.GenerateSalt(); // hashedPassword = Crypto.HashPassword(password); // // First parameter is the previously hashed string using a Salt // verify = Crypto.VerifyHashedPassword("{hash_password_here}", password); //} editUserSub.SaveChanges(); } } } catch (Exception ex) { throw ex; } }
//Email Dept Manager and User protected void emailDetails(TestProject.request RequestInfo) { DateTime StartDateTime = Convert.ToDateTime(RequestInfo.startDate + RequestInfo.startTime); DateTime EndDateTime = Convert.ToDateTime(RequestInfo.endDate + RequestInfo.endTime); string userEmail; string supervisorEmail; TestProject.userAccount user1; using (var PCTContext = new PCTEntities()) { user1 = (from ua in PCTContext.userAccounts join u in PCTContext.employees on ua.emp_id equals u.ID where ua.ID.ToString() == current_user select ua).First(); userEmail = user1.email; string supervisor_id = user1.supervisor.ToString(); //get supervisors email var selectSupervisor = (from s in PCTContext.userAccounts where s.ID.ToString() == supervisor_id select s).First(); supervisorEmail = selectSupervisor.email; //hardcode Request :( string type; if (RequestInfo.requestType_id.ToString() == "0") { type = "Personal"; } else { type = "Vacation"; } string lunchInfo; if (MultiView1.ActiveViewIndex == 2) { lunchInfo = "YES"; } else { if (LunchCheckBoxPD.Checked) { lunchInfo = "YES " + lunch.Text + " Minutes"; } else { lunchInfo = "NO "; } } // Create email message string emailMessage = ""; emailMessage += "<html>"; emailMessage += " <head>"; emailMessage += " <style>"; emailMessage += " h1{margin: 0;}"; emailMessage += " p{margin: 0; height: auto;}"; emailMessage += " </style>"; emailMessage += " </head>"; emailMessage += " <body>"; emailMessage += " <h1>Request off Submission Details:</h1>"; emailMessage += " <h2>Employee: " + user1.first_name + " " + user1.last_name + "<br />Department: " + deptDropDownList.SelectedItem.ToString() + "</h2>"; emailMessage += " <h3>Request Info:<h3>"; emailMessage += "<p>Start Date/Time: " + StartDateTime + "<br />End Date/Time: " + EndDateTime + "<br />Type: " + type + "<br />Request Submitted: " + RequestInfo.submitted + "<br/>Comments: " + RequestInfo.comments; emailMessage += "<br />Total Hours: " + RequestInfo.totalHours + "<br/>Status: " + RequestInfo.status + "<br />Lunch included? " + lunchInfo + "</p>"; emailMessage += " </body>"; emailMessage += "</html>"; MailMessage Usermessage = new MailMessage(); MailMessage Supervisormessage = new MailMessage(); SmtpClient smtpClient = new SmtpClient(); string msg = string.Empty; try { MailAddress fromAddress = new MailAddress("*****@*****.**"); //Customize user message Usermessage.From = fromAddress; //Usermessage.To.Add(userEmail); Usermessage.To.Add("*****@*****.**"); Usermessage.Subject = "Request Off Confirmation Email"; Usermessage.IsBodyHtml = true; Usermessage.Body = emailMessage; //Customize supervisor message Supervisormessage.From = fromAddress; //Supervisormessage.To.Add(supervisorEmail); Supervisormessage.To.Add("*****@*****.**"); Supervisormessage.Subject = "New Request Off"; Supervisormessage.IsBodyHtml = true; Supervisormessage.Body = emailMessage; //message.Attachments.Add(new Attachment(Server.MapPath("uploads/Appointment2.ics"))); smtpClient.Host = "smtp.gmail.com"; smtpClient.Port = 587; smtpClient.EnableSsl = true; //smtpClient.UseDefaultCredentials = true; smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Regscan1234"); smtpClient.Send(Usermessage); smtpClient.Send(Supervisormessage); //litAlert.Text = "Successful"; } catch (Exception ex) { throw ex; //litAlert.Text = ex.Message; } } }
protected void submitPD(object sender, EventArgs e) { request PDRequest = new request(); decimal totalHours; try { using (var PDreqcontext = new PCTEntities()) { PDRequest.dept_id = Convert.ToInt32(deptDropDownList.SelectedValue); PDRequest.requestType_id = Convert.ToInt32(TypeRequest_dropdown.SelectedValue); PDRequest.userAccount_id = Convert.ToInt32(current_user); PDRequest.created = requestStarted; PDRequest.submitted = DateTime.Now; //startDate is datetime instead of date. DateTime fromDate = Convert.ToDateTime(datepickerSingle.Value); DateTime toDate = Convert.ToDateTime(datepickerSingle.Value); PDRequest.startDate = fromDate.Date; PDRequest.endDate = toDate.Date; var start = PDstartTime.Text; //fix var end = PDendTime.Text; DateTime start2 = Convert.ToDateTime(start); DateTime end2 = Convert.ToDateTime(end); PDRequest.startTime = TimeSpan.Parse(start); PDRequest.endTime = TimeSpan.Parse(end); totalHours = Convert.ToDecimal((end2 - start2).TotalHours);//switch the to and from PDRequest.totalHours = Convert.ToDecimal(totalHours); PDRequest.status = "Pending"; PDRequest.comments = commentbox.Text.Trim(); //CREATE GOOGLE CALENDAR EVENT CreateCalEvent(PDRequest); //inserts the google calendar event id PDRequest.eventID = insertedEventId; //update userAccount forcasted and current available hours PDreqcontext.requests.Add(PDRequest); PDreqcontext.SaveChanges(); } //Update used V hours and P hours using (var useracct2 = new PCTEntities()) { var subLunch = (Convert.ToDecimal(LunchPD.Text) / 60); var user2 = (from u in useracct2.userAccounts where u.ID.ToString() == current_user select u).First(); if (TypeRequest_dropdown.SelectedValue == "0")//Personal Type { if (!LunchCheckBoxPD.Checked) { user2.usedPHours = Convert.ToDecimal(totalHours + user2.usedPHours); } else { user2.usedPHours = Convert.ToDecimal((totalHours + user2.usedPHours) - subLunch); } } else //Type is Vacation { if (!LunchCheckBoxPD.Checked) { user2.usedVHours = Convert.ToDecimal(totalHours + user2.usedVHours); } else { user2.usedVHours = Convert.ToDecimal((totalHours + user2.usedVHours) - subLunch); } } useracct2.SaveChanges(); } } catch (Exception ex) { throw ex; } //email to supervisor and user emailDetails(PDRequest); //redirect to beginning Response.Redirect("RequestOff.aspx"); }
//when a user clicks submit for a full day request off protected void submitFD(object sender, EventArgs e) { request FDRequest = new request(); decimal totalHours; try { using (var FDreqcontext = new PCTEntities()) { FDRequest.dept_id = Convert.ToInt32(deptDropDownList.SelectedValue); FDRequest.requestType_id = Convert.ToInt32(TypeRequest_dropdown.SelectedValue); FDRequest.userAccount_id = Convert.ToInt32(current_user); FDRequest.created = requestStarted; FDRequest.submitted = DateTime.Now; //startDate is datetime instead of date. DateTime fromDate = Convert.ToDateTime(from.Value); DateTime toDate = Convert.ToDateTime(to.Value); //format date //var fromDate2 = fromDate.Date; //var toDate2 = toDate.Date; int dateDiff = Convert.ToInt32(((toDate - fromDate).TotalDays) + 1);//switch the to and from totalHours = ((dateDiff * (Convert.ToDecimal(fullDayHours.Text) - Convert.ToDecimal(Convert.ToDecimal(lunch.Text) / 60)))); FDRequest.startDate = fromDate; FDRequest.endDate = toDate; FDRequest.totalHours = Convert.ToDecimal(totalHours); //time string newFromDate = fromDate.ToString("hh:mm"); string newToDate = toDate.ToString("hh:mm"); FDRequest.startTime = TimeSpan.Parse(newFromDate); FDRequest.endTime = TimeSpan.Parse(newToDate); FDRequest.status = "Pending"; FDRequest.comments = commentBox2.Text.Trim(); //CREATE GOOGLE CALENDAR EVENT CreateCalEvent(FDRequest); //inserts the google calendar event id FDRequest.eventID = insertedEventId; //update userAccount forcasted and current available hours FDreqcontext.requests.Add(FDRequest); FDreqcontext.SaveChanges(); } var subLunchFd = (Convert.ToDecimal(lunch.Text) / 60); //Update used V hours and P hours using (var useracct = new PCTEntities()) { var user = (from u in useracct.userAccounts where u.ID.ToString() == current_user select u).First(); if (TypeRequest_dropdown.SelectedValue == "0")//Personal Type { user.usedPHours = Convert.ToDecimal((totalHours + user.usedPHours) - subLunchFd); } else //Type is Vacation { user.usedVHours = Convert.ToDecimal((totalHours + user.usedVHours) - subLunchFd); } useracct.SaveChanges(); } } catch (Exception ex) { throw ex; } //email to supervisor and user emailDetails(FDRequest); //redirect to beginning Response.Redirect("RequestOff.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (Session["USER"] != null) { current_user = (string)(Session["USER"]); } else { Response.Redirect("Login.aspx"); } try { using (var PCTModel = new PCTEntities()) { var selectedUser = (from ua in PCTModel.userAccounts join u in PCTModel.employees on ua.emp_id equals u.ID where ua.ID.ToString() == current_user select ua).First(); requestStarted = DateTime.Now; string supervisor_id = selectedUser.supervisor.ToString(); fullDayHours.Text = selectedUser.fullDayHours.ToString(); lunch.Text = selectedUser.lunch.ToString(); LunchPD.Text = selectedUser.lunch.ToString(); var selectSupervisor = (from s in PCTModel.userAccounts where s.ID.ToString() == supervisor_id select s).First(); deptManagerbox.Text = (string)(selectSupervisor.first_name + ' ' + selectSupervisor.last_name); creatorbox.Text = (selectedUser.first_name + ' ' + selectedUser.last_name).ToString(); deptDropDownList.SelectedValue = selectedUser.employee.dept_id.ToString(); decimal carryOverV = Convert.ToDecimal(selectedUser.vacation_carryOver); decimal carryOverP = Convert.ToDecimal(selectedUser.personal_carryOver); DateTime today = DateTime.Today; DateTime hireDate = Convert.ToDateTime(selectedUser.employee.hireDate); decimal PersonalMax = 40; var daysOfEmployment = Convert.ToDecimal((today - hireDate).TotalDays); calc_timeAvailable(daysOfEmployment); //if an employee's lenght of employment turned 1 year this year then calculate their available hours based on the month they were employed for a year var startBenefitsDate = hireDate.AddYears(1); decimal PredictedVHours; decimal PredictedPHours; decimal accruedVHours = 0; decimal accruedPHours = 0; if (startBenefitsDate.ToString("yyyy") == today.ToString("yyyy")) { int hiredateMnum = hireDate.Month; var MonthsLeftofYear = (12 - hiredateMnum); PredictedVHours = MonthsLeftofYear * 8; PredictedPHours = MonthsLeftofYear * 4; //cannot exceed the max allowed for the year if (PredictedVHours > 80) { PredictedVHours = 80; } if (PredictedPHours > 40) { PredictedPHours = 40; } forecastedVHrs.Text = (PredictedVHours + selectedUser.vacation_carryOver).ToString(); forecastedPHrs.Text = (PredictedPHours + selectedUser.personal_carryOver).ToString(); //calc currently available hours if (today > startBenefitsDate) { int mtoday = today.Month; int mstartdate = startBenefitsDate.Month; int monthDiff = (mtoday - mstartdate); if (monthDiff != 0) { accruedVHours = monthDiff * 8; accruedPHours = monthDiff * 4; var remainingVHrs = (accruedVHours - selectedUser.usedVHours); var remainingPHrs = (accruedPHours - selectedUser.usedPHours); vacationHrsbox.Text = (accruedVHours.ToString() + " / " + remainingVHrs.ToString()); personalHrsbox.Text = accruedPHours.ToString() + " / " + remainingPHrs.ToString(); } else { vacationHrsbox.Text = (" 0 / 0 "); personalHrsbox.Text = (" 0 / 0 "); } } //Set the textboxes to display hours remaining and total hours } else if (daysOfEmployment < 365) { vacationHrsbox.Text = (" 0 / 0 "); personalHrsbox.Text = (" 0 / 0 "); } else { PredictedVHours = (vacationMax + carryOverV); PredictedPHours = (PersonalMax + carryOverP); var thisMonth = today.Month; var currentVHrsAvailable = Convert.ToDecimal(thisMonth) * monthlyVacation; var currentPHrsAvailable = Convert.ToDecimal(thisMonth) * monthlyPersonal; accruedVHours = currentVHrsAvailable + carryOverV; accruedPHours = currentPHrsAvailable + carryOverP; } //double mv = monthlyVacation; //double mp = monthlyPersonal; var remainingVHrs2 = (accruedVHours - selectedUser.usedVHours); var remainingPHrs2 = (accruedPHours - selectedUser.usedPHours); vacationHrsbox.Text = vacationHrsbox.Text = (accruedVHours.ToString() + " / " + remainingVHrs2.ToString()); personalHrsbox.Text = (accruedPHours.ToString() + " / " + remainingPHrs2.ToString()); //Lastly set carry over if (DateTime.Today == firstDay) { calc_carryOVer(accruedVHours, accruedPHours); selectedUser.personal_carryOver = Convert.ToDecimal(personalLeft); selectedUser.vacation_carryOver = Convert.ToDecimal(vacationLeft); } } } catch (Exception ex) { throw ex; } SummaryPanel.Visible = true; }
private void CreateCalEvent(TestProject.request request) { //Get details of request string userEmail; //string supervisorEmail; string fullname; TestProject.userAccount user1; using (var Googlecontext = new PCTEntities()) { user1 = (from ua in Googlecontext.userAccounts join u in Googlecontext.employees on ua.emp_id equals u.ID where ua.ID.ToString() == request.userAccount_id.ToString() select ua).First(); userEmail = user1.email; fullname = (user1.first_name + " " + user1.last_name + " Off - Pending"); string supervisor_id = user1.supervisor.ToString(); //get supervisors email var selectSupervisor = (from s in Googlecontext.userAccounts where s.ID.ToString() == supervisor_id select s).First(); //supervisorEmail = selectSupervisor.email; } var certificate = new X509Certificate2(@"C:\Users\glinn\Source\Repos\TestProject\TestProject\SeniorProject-ee5b3ab2ec84.p12", "notasecret", X509KeyStorageFlags.Exportable); var serviceAccountEmail = "*****@*****.**"; ServiceAccountCredential credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { Scopes = scopes }.FromCertificate(certificate)); // Create the service. CalendarService service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "SeniorProject", }); Google.Apis.Calendar.v3.Data.Event calEvent = new Google.Apis.Calendar.v3.Data.Event(); //Title of the event calEvent.Summary = fullname; calEvent.ColorId = "5"; //calEvent.Description = ""; //Department calEvent.Location = deptDropDownList.SelectedItem.ToString(); if (fullday == true) { DateTime newform = Convert.ToDateTime(request.startDate); DateTime newform2 = Convert.ToDateTime(request.startDate); calEvent.Start = new Google.Apis.Calendar.v3.Data.EventDateTime { DateTime = newform }; calEvent.End = new Google.Apis.Calendar.v3.Data.EventDateTime { DateTime = newform2 }; //new Google.Apis.Calendar.v3.Data.EventDateTime { DateTime = request.startDate.ToString("yyyy-mm-dd") } } else { calEvent.Start = new Google.Apis.Calendar.v3.Data.EventDateTime { DateTime = request.startDate + request.startTime }; calEvent.End = new Google.Apis.Calendar.v3.Data.EventDateTime { DateTime = request.endDate + request.endTime }; } //calEvent.Attendees = //calEvent.Attendees = new Google.Apis.Calendar.v3.Data.EventAttendee[] //{ //new Google.Apis.Calendar.v3.Data.EventAttendee() { Email = "*****@*****.**"}, //new Google.Apis.Calendar.v3.Data.EventAttendee() { Email = "*****@*****.**"} //}; var newEventRequest = service.Events.Insert(calEvent, "*****@*****.**"); var eventResult = newEventRequest.Execute(); //get event id insertedEventId = eventResult.Id; }