public async Task <IActionResult> Create([Bind("Id,ResignDate,Comment,CreatedDate,ApprovedDate,Status,Year,FromEmployeeInfoId,ToEmployeeInfoId")] ResignViewModel resign) { if (ModelState.IsValid) { Resign re = new Resign() { ResignDate = DateTime.Now, Comment = resign.Comment, CreatedDate = DateTime.Now, ApprovedDate = DateTime.Now, Status = "Pending", Year = DateTime.Now.Year.ToString(), FromEmployeeInfoId = resign.FromEmployeeInfoId, ToEmployeeInfoId = resign.ToEmployeeInfoId }; //_context.Add(resign); //await _context.SaveChangesAsync(); await resignRepository.Save(re); return(RedirectToAction(nameof(Index))); } ViewData["FromEmployeeInfoId"] = new SelectList(employeeInfoRepository.GetEmployeeInfoList(), "Id", "Id", resign.FromEmployeeInfoId); ViewData["ToEmployeeInfoId"] = new SelectList(employeeInfoRepository.GetEmployeeInfoList(), "Id", "Id", resign.ToEmployeeInfoId); return(View(resign)); }
public async Task <IActionResult> Create([Bind("Id,ResignDate,ResignStatus,Comment,Remark,CreatedDate,ApprovedDate,Status,Year,EmployeeInfoId")] ResignViewModel resign) { if (ModelState.IsValid) { Resign re = new Resign() { ResignDate = resign.ResignDate, ResignStatus = resign.ResignStatus, Comment = resign.Comment, Remark = resign.Remark, CreatedDate = resign.CreatedDate, ApprovedDate = resign.ApprovedDate, Status = resign.Status, Year = resign.Year, EmployeeInfoId = resign.EmployeeInfoId }; //_context.Add(resign); //await _context.SaveChangesAsync(); await resignRepository.Save(re); return(RedirectToAction(nameof(Index))); } ViewData["EmployeeInfoId"] = new SelectList(employeeInfoRepository.GetEmployeeInfoList(), "Id", "Id", resign.EmployeeInfoId); return(View(resign)); }
public async Task <bool> DisableResignUser(ResignViewModel resignModel) //From Staff Document { using (IDbConnection dbConnection = Connection) { string sQuery = @" if exists (select * from Resign where StaffID = @StaffID AND Convert(Date,@AppDate) = Convert(Date,AppDate) ) delete From Resign where StaffID = @StaffID AND Convert(Date,@AppDate) = Convert(Date,AppDate)"; //from positionassign pa inner join position p on p.MPLID = pa.MPLID where pa.StaffID = @StaffId"; dbConnection.Open(); try { var result = dbConnection.Execute(sQuery, resignModel); switch (result) { case 1: return(true); // await dbConnection.QueryAsync<ResignViewModel>(sQuery); // dbConnection.Execute(sQuery, resignModel); //await _ctxRepo.Resign(resignModel.StaffID, resignModel.AppDate); default: return(false); } // return true; } catch (Exception e) { Console.Write(e); return(false); } finally { } } }
public async Task <bool> ResignUser(ResignViewModel resignModel) //From Staff Document { using (IDbConnection dbConnection = Connection) { string sQuery = @" if exists (select * from Resign where StaffID = @StaffID AND Convert(Date,@AppDate) = Convert(Date,AppDate) ) update Resign set ApplicationType=@ApplicationType,DateModified=@DateModified,ManagerReason=@ManagerReason,Reason=@Reason,JobTitleWhenResigned=@JobTitleWhenResigned,ReasonForResignment=@ReasonForResignment,ResignComm=@ResignComm,Signature=@Signature,Recommend=@Recommend,Status='Received', AppDate=@AppDate,FromDate=@FromDate,Destination=(select top 1 Destination from Position t2 Join PositionAssign t1 on @StaffID = t1.StaffID Where t2.MPLID=t1.MPLID ) Where StaffID=@StaffID AND Convert(Date,@AppDate) = Convert(Date,AppDate); else Insert Into Resign (StaffID,ManagerReason, JobTitleWhenResigned,Destination,DateModified,FromDate,AppDate,ReasonForResignment,Reason,ApplicationType,ResignComm,Signature,Recommend,Status) select @StaffID,@ManagerReason, @JobTitleWhenResigned, (select top 1 Destination from Position t2 Join PositionAssign t1 on @StaffID = t1.StaffID Where t2.MPLID=t1.MPLID),getdate(), @FromDate,@AppDate,@ReasonForResignment,@Reason,@ApplicationType,@ResignComm,@Signature,@Recommend,'Received'"; //from positionassign pa inner join position p on p.MPLID = pa.MPLID where pa.StaffID = @StaffId"; dbConnection.Open(); try { dbConnection.Execute(sQuery, resignModel); await _ctxRepo.Resign(resignModel.StaffID, resignModel.AppDate); return(true); } catch (Exception e) { Console.Write(e); return(false); } finally { } } }
public void Add(ResignViewModel add) //oneshot { //if (CheckAssign(assignation) == true) //{ using (var connection = new SqlConnection(connectionString)) { string sql = @" if exists (select * from Resign where StaffID = @StaffID) update Resign set ApplicationType=@ApplicationType,DateModified=@DateModified,ManagerReason=@ManagerReason,Reason=@Reason,jobTitleWhenResigned=@JobTitleWhenResigned,ReasonForResignment=@ReasonForResignment, AppDate=@AppDate,FromDate=@FromDate,Destination=@Destination,Signature=@Signature,ResignComm=@ResignComm Where StaffId=@StaffID; else Insert Into Resign (StaffID,ManagerReason, DateModified,FromDate,AppDate,ReasonForResignment,Reason,ApplicationType,JobTitleWhenResigned,Destination,Signature,ResignComm) Values (@StaffID,@ManagerReason,@DateModified,@FromDate,@AppDate,@ReasonForResignment,@Reason,@ApplicationType,@JobTitleWhenResigned,@Destination,@Signature,@ResignComm)"; connection.Execute(sql, new { add.ApplicationType, add.StaffID, add.Status, add.DateModified, add.JobTitleWhenResigned, add.ReasonForResignment, add.Reason, add.ManagerReason, add.Signature, add.Approver, add.ResignComm, add.DecDate, add.FromDate, add.AppDate, add.Destination, }); } //} }
public async Task <bool> DisableResignUser([FromBody] ResignViewModel resignModel) //From StaffDoc { DateTime?ParsedFromDate = resignModel.AppDate; DateTime TodayDate = DateTime.Now; UserModel UserName = _userRepo.GetUser(); if (ParsedFromDate >= TodayDate) { // ok this is a full abscense with status change in Staff the full Monty var res1 = await _resignRepo.DisableResignUser(resignModel); //var res2 = _resignRepo.UpdateUser(resignModel.StaffID); if (res1) { //if (res2) //{ var History = new HistoryModel(); // Add to History all actions of relevancy { History.StaffID = resignModel.StaffID; History.HistoryDate = resignModel.AppDate; History.HistoryAction = "DISABLE RESIGNATION"; History.HistoryLocation = "Some Destínation"; History.ApplicationType = "Resign"; History.DateModified = DateTime.UtcNow; History.Status = "Received"; History.HistoryWho = UserName.UserName; History.JobTitleWhenResigned = resignModel.JobTitleWhenResigned; // History.HistoryWho = System.Security.Principal.WindowsIdentity.GetCurrent().Name; }; _historyRepo.UpdateHistoryResign(History); //var staff = _staffRepos.GetByStaffIdResign(resignModel.StaffID); //var templates = _mailRepos.GetTemplate("ResignMail"); //await _mailRepos.SendMailStaff(templates, staff); // with full data for the Placement team //if (resignModel.ManagerReason != "Dismissed") //{ // var mailReturn = _mailRepos.SendMail(templates, staff); // to the Staff //} ////var mailReturn = _mailRepos.SendMail(templates, staff); // to the Staff //_resignRepo.DeleteUserInPosAssign(resignModel.StaffID); //return true; } else { return(false); } } return(true); }