public async Task <ActionResult> Create(States collection) { try { // TODO: Add insert logic here ModelState.Remove("Id"); if (ModelState.IsValid) { if (collection.Id == Guid.Empty) { await APIHelpers.PostAsync <States>("api/State/Post", collection); TempData["sucess"] = StateResources.create; } else { await APIHelpers.PutAsync <States>("api/State/Put", collection); TempData["sucess"] = StateResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(TemplatesType collection) { try { ModelState.Remove("Id"); if (ModelState.IsValid) { if (collection.Id == Guid.Empty) { await APIHelpers.PostAsync <TemplatesType>("api/TemplateType/Post", collection); TempData["sucess"] = TemplateTypeResources.create; } else { await APIHelpers.PutAsync <TemplatesType>("api/TemplateType/Put", collection); TempData["sucess"] = TemplateResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { throw; } }
public async Task <ActionResult> Create(Skills collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here if (collection.Id == Guid.Empty) { await APIHelpers.PostAsync <Skills>("api/Skill/Post", collection); TempData["sucess"] = SkillsResources.create; } else { await APIHelpers.PutAsync <Skills>("api/Skill/Put", collection); TempData["sucess"] = SkillsResources.update; } return(RedirectToAction("Index")); } else { return(View(collection)); } } catch (Exception ex) { TempData["error"] = CommonResources.error; return(RedirectToAction("AccessDenied", "Error")); } }
public async Task <JsonResult> PostSkill(string name) { try { if (name != "") { Skills skill = new Skills { Id = Guid.Empty, Name = name }; await APIHelpers.PostAsync <Skills>("api/Skill/Post", skill); return(Json(true, JsonRequestBehavior.AllowGet)); } else { return(Json(false, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { throw; } }
public async Task <ActionResult> Create(Interviews model) { try { //var c = Request["CandidateId"]; var stime = Request["Stime"]; var sdate = Request["Sdate"]; DateTime time = Convert.ToDateTime(DateTime.ParseExact(sdate, "MM/dd/yyyy", null) + DateTime.Parse(stime).TimeOfDay); ModelState.Remove("Id"); ModelState.Remove("ScheduleTime"); if (ModelState.IsValid) { model.ScheduleTime = time; if (model.Id == Guid.Empty) { await APIHelpers.PostAsync <Interviews>("api/Interview/Post", model); TempData["sucess"] = InterviewResources.create; } else { await APIHelpers.PutAsync <Interviews>("api/Interview/Put", model); TempData["sucess"] = InterviewResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(HttpPostedFileBase Logo, SettingView collection) { try { //HttpPostedFileBase file; //if (Logo != null && !string.IsNullOrEmpty(Logo.FileName)) { //Logo.SaveAs(Server.MapPath("~/Images/" + Logo.FileName)); //collection.Logo = Logo.FileName; //} // TODO: Add insert logic here ModelState.Remove("Id"); ModelState.Remove("Header"); ModelState.Remove("SubHeader"); ModelState.Remove("Logo"); ModelState.Remove("ShowDate"); if (ModelState.IsValid) { await APIHelpers.PostAsync <SettingView>("api/Setting/Post", collection); TempData["sucess"] = "Setting Updated Successfully"; } return(RedirectToAction("Create")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(Interviewers model) { try { var fromtime = Request["FromTime"]; var totime = Request["ToTime"]; //var ftime = TimeSpan.Parse(fromtime, CultureInfo.InvariantCulture); ModelState.Remove("FromTime"); ModelState.Remove("ToTime"); ModelState.Remove("Id"); if (ModelState.IsValid) { model.FromTime = DateTime.Parse(fromtime).TimeOfDay; model.ToTime = DateTime.Parse(totime).TimeOfDay; if (model.Id == Guid.Empty) { await APIHelpers.PostAsync <Interviewers>("api/Interviewer/Post", model); TempData["sucess"] = InterviewerResources.create; } else { await APIHelpers.PutAsync <Interviewers>("api/Interviewer/Put", model); TempData["sucess"] = InterviewerResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(HttpPostedFileBase[] Documents, ProjectTeamViewModel collection) { try { string employees = string.Join(",", Request["Employees"]); ModelState.Remove("Id"); ModelState.Remove("Documents"); ModelState.Remove("EmployeeId"); ModelState.Remove("CurrentlyWorking"); if (ModelState.IsValid) { collection.Documents = ""; //foreach (HttpPostedFileBase file in Documents) //{ // if (file != null) // { // var filename = Path.GetFileName(file.FileName); // collection.Documents = collection.Documents + " " + filename; // var serverpath = Path.Combine(Server.MapPath("~/ProjectDocuments/") + filename); // file.SaveAs(serverpath); // } //} //ViewBag.Employees = await APIHelpers.GetAsync<List<Employee>>("api/Employee/GetEmployees"); For when redirect to same view this statement is ndeeded for Employee Dropdown if (collection.Id == Guid.Empty) { //var data = await APIHelpers.PostAsync<Projects>("api/Project/Post", collection); //collection.Id = data.Id; await APIHelpers.PostAsync <Projects>("api/Project/Post", collection); TempData["sucess"] = ProjectResources.create; } else { collection.EmployeeId = employees; await APIHelpers.PutAsync <Projects>("api/Project/Put", collection); TempData["sucess"] = ProjectResources.update; } return(RedirectToAction("Index")); //return View("Create", collection); //For redirect to same view } else { return(View(collection)); } } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(Notifications collection) { try { ModelState.Remove("From"); ModelState.Remove("To"); if (ModelState.IsValid) { collection.From = DateTime.Now.Date; var todate = Convert.ToDouble(Request["Duration"]); if (todate == 0) { TempData["error"] = NotificationResources.duration; return(View(collection)); } else { collection.To = DateTime.Now.Date.AddDays(todate - 1); } //collection.To = DateTime.Now.Date.AddDays(Convert.ToDouble(Request["Duration"])); // TODO: Add insert logic here if (collection.Id == Guid.Empty) { await APIHelpers.PostAsync <Notifications>("api/Notification/Post", collection); TempData["sucess"] = NotificationResources.create; } else { await APIHelpers.PutAsync <Notifications>("api/Notification/Put", collection); TempData["sucess"] = NotificationResources.update; } return(RedirectToAction("Index")); } else { return(View(collection)); } } catch (Exception ex) { TempData["error"] = CommonResources.error; return(RedirectToAction("AccessDenied", "Error")); } }
public async Task <ActionResult> Create(CandidateViewModel model) { try { string dt = Request["Birthdate"]; ModelState.Remove("Id"); ModelState.Remove("Experience"); ModelState.Remove("BirthDate"); model.Skills = string.Join(",", Request["Skill"]); model.Technology = string.Join(",", Request["Technology"]); var d = decimal.Parse("20.03"); var d2 = Convert.ToDecimal("20.03"); if (ModelState.IsValid) { model.BirthDate = DateTime.ParseExact(dt, "MM/dd/yyyy", null); var month = Convert.ToDecimal(Request["Month"]); if (month < 10) { model.Experience = Convert.ToDecimal(Request["Year"] + "." + "0" + Request["Month"]); } else { model.Experience = Convert.ToDecimal(Request["Year"] + "." + Request["Month"]); } if (model.Id == Guid.Empty) { await APIHelpers.PostAsync <CandidateViewModel>("api/Candidate/Post", model); TempData["sucess"] = CandidateResources.create; } else { await APIHelpers.PutAsync <CandidateViewModel>("api/Candidate/Put", model); TempData["sucess"] = CandidateResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> Create(Openings model) { try { ModelState.Remove("Id"); ModelState.Remove("CreatedDate"); ModelState.Remove("Experience"); if (ModelState.IsValid) { var month = Convert.ToDecimal(Request["Month"]); if (month < 10) { month = Convert.ToDecimal("0" + month); } else { month = Convert.ToDecimal(Request["Month"]); } var exp = Request["Year"] + "." + month; model.Experience = Convert.ToDecimal(exp); model.Skills = string.Join(",", Request["Skill"]); if (model.Id == Guid.Empty) { model.CreatedDate = DateTime.Now.Date; //model.Skills = string.Join(",", Request["Skill"]); var data = await APIHelpers.PostAsync <Openings>("api/Openings/Post", model); TempData["sucess"] = OpeningResources.create; } else { var data = await APIHelpers.PutAsync <Openings>("api/Openings/Put", model); TempData["sucess"] = OpeningResources.update; } } return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public async Task <ActionResult> UploadExcel(HttpPostedFileBase FileUpload) { List <string> data = new List <string>(); if (Request.Files["FileUpload1"].ContentLength > 0) { string extension = System.IO.Path.GetExtension(Request.Files["FileUpload1"].FileName).ToLower(); string connString = ""; List <Skills> skills = new List <Skills>(); string[] validFileTypes = { ".xls", ".xlsx", ".csv" }; string path1 = string.Format("{0}/{1}", Server.MapPath("~/Content/Uploads"), Request.Files["FileUpload1"].FileName); if (!Directory.Exists(path1)) { Directory.CreateDirectory(Server.MapPath("~/Content/Uploads")); } if (validFileTypes.Contains(extension)) { if (System.IO.File.Exists(path1)) { System.IO.File.Delete(path1); } Request.Files["FileUpload1"].SaveAs(path1); if (extension == ".csv") { skills = Utility.ConvertCSVtoDataTable(path1); } //Connection String to Excel Workbook else if (extension.Trim() == ".xls") { connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path1 + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\""; skills = Utility.ConvertXSLXtoDataTable(path1, connString); } else if (extension.Trim() == ".xlsx") { connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path1 + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\""; skills = Utility.ConvertXSLXtoDataTable(path1, connString); } foreach (var a in skills) { await APIHelpers.PostAsync <Skills>("api/Skill/Post", new Skills() { Name = a.Name }); } //deleting excel file from folder if ((System.IO.File.Exists(path1))) { System.IO.File.Delete(path1); } return(RedirectToAction("Index")); } else { TempData["error"] = "Please Upload Files in .xls, .xlsx or .csv format"; return(RedirectToAction("CreateBulk")); } } else { TempData["error"] = CommonResources.error; return(RedirectToAction("CreateBulk")); } }
public async Task <ActionResult> Create(HttpPostedFileBase[] Attachment, Leave collection) { try { string from = Request["From"]; string to = Request["To"]; ModelState.Remove("Attachment"); ModelState.Remove("Id"); ModelState.Remove("EmployeeId"); ModelState.Remove("From"); ModelState.Remove("To"); if (ModelState.IsValid) { collection.From = DateTime.ParseExact(from, "MM/dd/yyyy", null); collection.To = DateTime.ParseExact(to, "MM/dd/yyyy", null); collection.AssignTo = ""; collection.EmployeeId = Guid.Parse(EmployeeManagementSystem.Helper.CommonHelper.GetUserId()); collection.LeaveStatus = Enums.LeaveStatus.Pending; collection.Attachment = ""; foreach (HttpPostedFileBase file in Attachment) { if (file.FileName.Contains(".pdf") || file.FileName.Contains(".jpg") || file.FileName.Contains(".JPEG")) { if (file != null) { var filename = Path.GetFileName(file.FileName); collection.Attachment = collection.Attachment + " " + filename; var serverpath = Path.Combine(Server.MapPath("~/LeaveImage/") + filename); file.SaveAs(serverpath); } } else { TempData["error"] = LeaveResources.FileError; return(View()); } } // TODO: Add insert logic here if (collection.Id == Guid.Empty) { await APIHelpers.PostAsync <Leave>("api/Leave/Post", collection); var role = await _customerService.GetHR(); string temp = String.Join(",", role); string subject = "Request For Leave"; var body = await _customerService.GetLeaveTemplate(); var store = new UserStore <ApplicationUser>(new ApplicationDbContext()); var userManager = new UserManager <ApplicationUser>(store); ApplicationUser user = userManager.FindByNameAsync(User.Identity.Name).Result; var content = body.TemplateContent; content.Replace("###CurrentUser###", "Dhaval"); content = Regex.Replace(content, "###CurrentUser###", user.FirstName + " " + user.LastName); content = Regex.Replace(content, "###FromDate###", collection.From.ToString()); content = Regex.Replace(content, "###ToDate###", collection.To.ToString()); content = Regex.Replace(content, "###LeaveReason###", collection.Message); //CommonHelper.SendMail(temp, subject, content); TempData["sucess"] = LeaveResources.create; } else { await APIHelpers.PutAsync <Leave>("api/Leave/Put", collection); TempData["sucess"] = LeaveResources.update; } return(RedirectToAction("Index")); } else { return(View(collection)); } } catch (Exception ex) { TempData["error"] = CommonResources.error; return(RedirectToAction("AccessDenied", "Error")); } }