public async Task <JsonResult> UploadFile(int id) { if (Request.Files.Count > 0) { try { // Get all files from Request object HttpFileCollectionBase files = Request.Files; var activity = db.CompletedActivities.Where(x => x.ID == id); if (activity != null) { //activity.First().HasTaskBeenCompleted = true; // await db.SaveChangesAsync(); //db.SaveChanges(); // action = true; } for (int i = 0; i < files.Count; i++) { //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/"; //string filename = Path.GetFileName(Request.Files[i].FileName); HttpPostedFileBase file = files[i]; string fname; // Checking for Internet Explorer if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { string extension = Path.GetExtension(file.FileName); fname = activity.First().Name + activity.First().ID + extension; } // Get the complete folder path and store the file inside it. fname = Path.Combine(Server.MapPath("~/Uploads/"), fname); file.SaveAs(fname); } // Returns message that successfully uploaded await db.SaveChangesAsync(); return(Json(true, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Error occurred. Error details: " + ex.Message)); } } else { return(Json("No files selected.")); } }
public async Task <ActionResult> Create([Bind(Include = "BranchId,Location")] Branch branch) { if (ModelState.IsValid) { db.Branches.Add(branch); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(branch)); }
public async Task <ActionResult> Create([Bind(Include = "ID,LeaveAppID,EmployeeId,EmployeeName,StartDate,ResumptionDate,Duration,Status,ApplyDate,LeaveType")] LeaveResumption leaveResumption) { if (ModelState.IsValid) { db.LeaveResumptions.Add(leaveResumption); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(leaveResumption)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Sender,ProcessName,NoOfApprovals,Approver1Id,Approver2Id,Approver3Id,Approver4Id,Approver5Id,IsEnabled")] DocumentWorkFlow documentWorkFlow) { if (ModelState.IsValid) { db.ApprovalFlows.Add(documentWorkFlow); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(documentWorkFlow)); }
internal async Task <ActionResult> SaveBioDetails(JobSeeker applicant) { try { if (ModelState.IsValid) { using (var db = new TalentContext()) { var id = applicant.ID; var originaluserdata = GetUserProfile(id); originaluserdata.FirstName = applicant.FirstName; originaluserdata.LastName = applicant.LastName; originaluserdata.PhoneNumber = applicant.PhoneNumber; originaluserdata.Address = applicant.Address; originaluserdata.DateOfBirth = applicant.DateOfBirth; db.Entry(originaluserdata).State = EntityState.Modified; await db.SaveChangesAsync(); //db.SaveChanges(); } return(RedirectToAction("Education", "Applicant")); } return(View("ManageProfile", "Applicant", applicant)); } catch (Exception ex) { ModelState.AddModelError("", ex); return(View("Error")); //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } }
public async Task <ActionResult> Approve(string id, ExitInterview model) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExitInterview exitInterview = await db.ExitInterviews.FindAsync(id); if (exitInterview == null) { return(HttpNotFound()); } exitInterview.ApproveProcess = model.ApproveProcess; exitInterview.Status = "Approved"; await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create([Bind(Include = "LeaveAppID,LeavePlanID,EmployeeId,EmployeeName,LeaveType,LeaveLimit,TotalLeaveTaken,TotalLeaveAvailable,StartDate,EndDate,Duration,ApplyDate,LeavePlanStatus,LeaveAppStatus")] LeaveApplication leaveApplication) { if (ModelState.IsValid) { if (leaveApplication.LeaveLimit < leaveApplication.Duration) { ViewBag.LeaveType = new SelectList(db.LeaveType_Limits.ToList(), "LeaveType", "LeaveType"); ViewBag.Error = "Your " + leaveApplication.LeaveType + " Leave Duration Cannot exceed leave limit of " + leaveApplication.LeaveLimit + " days !"; leaveApplication.EndDate = leaveApplication.StartDate.AddDays((double)leaveApplication.LeaveLimit - 1); return(View(leaveApplication)); } db.LeaveApplications.Add(leaveApplication); await db.SaveChangesAsync(); //await Task.Delay(50); return(RedirectToAction("Index")); } return(View(leaveApplication)); }
internal async Task <ActionResult> SaveBioDetails(JobSeeker applicant) { //try //{ if (ModelState.IsValid) { using (var db = new TalentContext()) { var id = applicant.ID; var originaluserdata = GetUserProfile(id); originaluserdata.FirstName = applicant.FirstName; originaluserdata.LastName = applicant.LastName; originaluserdata.PhoneNumber = applicant.PhoneNumber; originaluserdata.Address = applicant.Address; originaluserdata.DateOfBirth = applicant.DateOfBirth; originaluserdata.IndustryID = applicant.IndustryID; originaluserdata.HighestQualification = applicant.HighestQualification; // originaluserdata.Skills.Add(db.Skills.Find(1)); // db.Entry(originaluserdata).State = EntityState.Modified; //await db.SaveChangesAsync(); // var skills = db.Skills.Include("JobSeekers").ToList(); var selectedint = applicant.Skills.Select(o => o.ID).ToList(); // var selectedint = new List<int>() {1,2,3 }; var skills = db.Skills .Where(x => selectedint.Contains(x.ID)) .ToList(); db.Entry(originaluserdata).State = EntityState.Modified; db.SaveChanges(); await Task.Delay(100); //originaluserdata.Skills = new List<Skill>(); originaluserdata.Skills.Union(skills); originaluserdata.Skills.Intersect(skills); originaluserdata.Skills = skills; //System.Threading.Thread.Sleep(500); await db.SaveChangesAsync(); } ViewBag.userid = applicant.ID; return(RedirectToAction("Profile", "Applicant")); } ViewBag.userid = applicant.ID; return(View("ManageProfile", "Applicant", applicant)); //} //catch (Exception ex) //{ // ModelState.AddModelError("", ex); // return View("Error"); // //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} }
public async Task <ActionResult> Create([Bind(Include = "Id,EmployeeID,EmployeeName,Title,Body,Deleted,CreatedAt,LastUpdatedAt")] Announcement announcement) { if (string.IsNullOrEmpty(announcement.Title) || string.IsNullOrEmpty(announcement.Body)) { ViewBag.Error = "Form was not Completed Properly"; return(View(announcement)); } var id = User.Identity.GetUserId(); var user = _employeeRepository.GetAll().Where(x => x.UserId == id).FirstOrDefault(); if (user == null) { return(View("Error")); } announcement.EmployeeID = user.EmployeeNumber; announcement.EmployeeName = user.FullName; announcement.CreatedAt = DateTime.Now; announcement.LastUpdatedAt = DateTime.Now; db.Announcements.Add(announcement); await db.SaveChangesAsync(); return(RedirectToAction("Dashboard", "Admin")); }