public string Leave(LeaveModel leaveModel) { if (!ModelState.IsValid) { Response.StatusCode = 400; // Bad Request return(Resources.Strings.CharRoomsError); } List <string> currentRooms = new List <string> { leaveModel.Room }; MvcApplication.Db.DelUser(currentRooms, (string)Session["nick"]); currentRooms.Clear(); currentRooms.AddRange(MvcApplication.Db.GetRooms((string)Session["nick"])); MvcApplication.Pub.Publish(Resources.Internals.RoomsEventChannel, JsonConvert.SerializeObject(MvcApplication.Db.GetRooms())); if (0 == currentRooms.Count) { MvcApplication.Db.DelUserFromGlobalList((string)Session["nick"]); Session.Abandon(); Response.StatusCode = 404; return(""); } return(JsonConvert.SerializeObject(currentRooms)); }
public async Task <IActionResult> Approve(int?id) { if (await extractUser()) { LeaveModel application = await _context.Leaves.FindAsync(id); user = await _context.Users.Include(u => u.leadedTeam).ThenInclude(u => u.devs).FirstOrDefaultAsync(u => u.id == user.id); if (user.role.name == "CEO" || (user.role.name == "Team Lead" && user.leadedTeam.devs.Any(d => d.leaves.Contains(application)))) { application.approved = true; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(IndexDisapproved))); } else { return(View("NoPermission")); } } else { return(RedirectToAction("Index", "LogIn")); } }
public async Task <IHttpActionResult> SetLeave(LeaveModel model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } user_leaveAPP app = new user_leaveAPP(); user_leaveEntity ent = new user_leaveEntity { id = System.Guid.NewGuid().ToString(), day = model.Day, day_type = model.DayType, desc = model.Desc, leave_type = model.LeaveType, StartDateTime = model.StartDateTime, EndDateTime = model.EndDateTime, userid = User.Identity.GetUserId() }; salesActualChangeRes res = app.leave(ent); if (!res.isOk) { return(BadRequest(res.errorMessage)); } return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> InsertLeave([FromBody] LeaveModel model) { using (var factory = new SqlConnectionFactory()) { return(Ok(await factory.InsertNewLeave(model))); } }
public ActionResult Index(LeaveModel model) { if (Session["USER"] == null) { RedirectToAction("Login", "Account"); } con = new OracleConnection("Data Source=HRMSDEV;user id=PERSON;password=PERSON;Unicode=True;"); if (Session["UserSecurity"].ToString() == "ADMIN") { da = new OracleDataAdapter("select EMPID,EMP_NAME,LEAVE_NAME,FROMLEAVE,TOLEAVE,DAYS,STATUS from TAMPIL_DETAIL_LEAVE WHERE AREA_CODE IN (" + Session["Autorized"] + ") ", con); } else { da = new OracleDataAdapter("select EMPID,EMP_NAME,LEAVE_NAME,FROMLEAVE,TOLEAVE,DAYS,STATUS from TAMPIL_DETAIL_LEAVE WHERE EMPID='" + Session["USER"] + "'", con); } da.Fill(ds); foreach (DataRow dr in ds.Tables[0].Rows) { LeaveModel.Add(new LeaveModel() { nik = dr[0].ToString(), empnm = dr[1].ToString(), namacuti = dr[2].ToString(), fromleave = DateTime.Parse(dr[3].ToString()), toleave = DateTime.Parse(dr[4].ToString()), totaldays = Convert.ToDouble(dr[5].ToString()), deskripsi = dr[6].ToString() }); } return(View(LeaveModel)); }
//public void CancelLeave(LeaveModel leaveModel) //{ // OracleConnection con = new OracleConnection(str); // con.Open(); // OracleCommand cmd = new OracleCommand("UPDATE LEAVETABLE SET LEAVE_STATUS = '"+leaveModel.leavestatus+"' WHERE EMP_ID = '"+leaveModel.empid+"' AND LEAVE_START = '"+leaveModel.startdate+"'",con); // cmd.CommandType = CommandType.Text; // cmd.ExecuteNonQuery(); // con.Close(); //} public void CancelLeave(LeaveModel leaveModel) { OracleConnection con = new OracleConnection(connStr); con.Open(); OracleCommand cmd = new OracleCommand("UPDATE_LEAVESTATUS", con); cmd.CommandType = CommandType.StoredProcedure; try { cmd.Parameters.Add("E_ID", leaveModel.empid); cmd.Parameters.Add("E_STARTDATE", leaveModel.startdate); cmd.Parameters.Add("E_LEAVESTATUS", leaveModel.leavestatus); cmd.ExecuteNonQuery(); } catch (Exception e) { throw e; } finally { con.Close(); cmd.Dispose(); } }
//Employee give a leave request to their manager public ActionResult LeaveRequest() { LeaveModel leaveModel = new LeaveModel(); leaveModel.EmployeeId = employeeBL.GetEmployeeIdByGmail(User.Identity.Name); return(View(leaveModel)); }
public static LeaveViewModel ToViewModel(this LeaveModel x) { if (x == null) { return(new LeaveViewModel()); } return(new LeaveViewModel { Id = x.Id, CreatedBy = x.CreatedBy, UpdatedBy = x.UpdatedBy, CreatedOn = x.CreatedOn, UpdatedOn = x.UpdatedOn, IsDeleted = x.IsDeleted, IsActive = x.IsActive, StartDate = x.StartDate, EndDate = x.EndDate, Description = x.Description, UserId = x.UserId, TotalCount = x.TotalCount, StartTime = x.StartTime, EndTime = x.EndTime, Type = x.Type, FullName = x.FullName }); }
public void LeaveUpdate(LeaveModel model) { using (var dbctx = DbContext) { dbctx.LeaveUpdate(model.Id, model.UpdatedBy, model.UpdatedOn, model.IsDeleted, model.IsActive, model.StartDate, model.EndDate, model.StartTime, model.EndTime, model.Type, model.Description, model.UserId); } }
public int AddLeave(LeaveModel model) { string sql = string.Format("insert into AllLeave values('{0}','{1}',{2},'{3}',{4})", model.lName, model.lPeople, model.lNum, model.lYuanYin, model.lTypeid); return(DBhelper.ExecuteNonQuery(sql)); }
public async Task <IHttpActionResult> AddLeave([FromBody] LeaveModel model) { var employeeId = GetEmployeeId(); var leave = await _leaveManager.AddMeAsync(model, employeeId); return(Ok(leave)); }
public static void RequestLeave(this Userx user, int ClassSelectID) { var db = new AppDbContext(); if (db.M_ProjectSelectModels.Find(ClassSelectID) == null) { throw new FPException("请假失败"); } if ((from t in db.M_LeaveModle where t.ClassID == ClassSelectID && t.StudentID == user.Origin.ID select 1).Count() > 0) { throw new FPException("已经请假"); } var model = new LeaveModel() { StudentID = user.Origin.ID, ClassID = ClassSelectID, IsApproved = false }; db.Entry(model).State = Microsoft.EntityFrameworkCore.EntityState.Added; db.SaveChanges(); }
public ActionResult ApplyLeave() { ViewBag.LeaveType = LeaveServices.GetAllLeaveType(); ViewBag.LeaveDuration = LeaveServices.GetAllLeaveDuration(); LeaveModel model = new LeaveModel(); return(View(model)); }
public long LeaveInsert(LeaveModel model) { using (var dbctx = DbContext) { var id = dbctx.LeaveInsert(model.CreatedBy, model.StartDate, model.EndDate, model.StartTime, model.EndTime, model.Type, model.Description, model.UserId).FirstOrDefault(); return(Convert.ToInt64(id ?? 0)); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string obj = context.Request["obj"]; LeaveModel model = JsonConvert.DeserializeObject <LeaveModel>(obj); context.Response.Write(bll.UptLeave(model)); }
public ActionResult LeaveRequest(LeaveModel leaveModel) { leaveModel.Status = "Pending"; var leaveRequest = AutoMapper.Mapper.Map <LeaveModel, Leave>(leaveModel); employeeBL.AddLeaveRequest(leaveRequest); return(View()); }
public List <LeaveModel> GetLeaveDetails(int empid) { List <LeaveModel> leavelist = new List <LeaveModel>(); OracleConnection con = new OracleConnection(connStr); con.Open(); OracleCommand cmd = new OracleCommand("GET_LEAVE", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("E_ID", empid); cmd.Parameters.Add("E_DISPLAY", OracleDbType.RefCursor).Direction = ParameterDirection.Output; OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { LeaveModel leaveModel = new LeaveModel(); if (!reader.IsDBNull(reader.GetOrdinal("LEAVE_TYPE"))) { leaveModel.leavetype = reader.GetString(reader.GetOrdinal("LEAVE_TYPE")); } if (!reader.IsDBNull(reader.GetOrdinal("LEAVE_START"))) { leaveModel.startdate = reader.GetDateTime(reader.GetOrdinal("LEAVE_START")); } if (!reader.IsDBNull(reader.GetOrdinal("LEAVE_END"))) { leaveModel.enddate = reader.GetDateTime(reader.GetOrdinal("LEAVE_END")); } if (!reader.IsDBNull(reader.GetOrdinal("LEAVE_DAYS"))) { leaveModel.leaveduration = reader.GetInt32(reader.GetOrdinal("LEAVE_DAYS")); } if (!reader.IsDBNull(reader.GetOrdinal("LEAVE_DESCRIPTION"))) { leaveModel.leavedescription = reader.GetString(reader.GetOrdinal("LEAVE_DESCRIPTION")); } if (!reader.IsDBNull(reader.GetOrdinal("LEAVE_STATUS"))) { leaveModel.leavestatus = reader.GetString(reader.GetOrdinal("LEAVE_STATUS")); } if (!reader.IsDBNull(reader.GetOrdinal("LEAVE_BALANCE"))) { leaveModel.leavebalance = reader.GetInt32(reader.GetOrdinal("LEAVE_BALANCE")); } leavelist.Add(leaveModel); } con.Close(); cmd.Dispose(); reader.Dispose(); return(leavelist); }
public tbl_Leaves GetLeavsOBFromLeaveModel(LeaveModel leaveModel) { var configuration = new MapperConfiguration(cfg => { cfg.CreateMap <LeaveModel, tbl_Leaves>(); }); IMapper mapper = configuration.CreateMapper(); Leaves = mapper.Map <LeaveModel, tbl_Leaves>(leaveModel); return(Leaves); }
public void CancelLeave(LeaveModel leaveModel) { //LeaveModel leaveModel = new LeaveModel(); leaveModel.empid = (int)Session["empid2"]; leaveModel.leavestatus = "Cancel Applied"; leaveModel.startdate = Convert.ToDateTime(leaveModel.startdate); EmployeeManager employeeManager = new EmployeeManager(); employeeManager.CancelLeave(leaveModel); }
public static Dictionary <string, object> ConvertLeave(this LeaveModel leave) { return(new Dictionary <string, object> { { "LeaveID", leave.ID }, { "StudentID", leave.StudentID }, { "TeacherID", leave.TeacherID }, { "ClassID", leave.ClassID } }); }
public async Task <bool> InsertNewLeave(LeaveModel model) { string sb; if (model.From.HasValue && model.From.HasValue) { sb = "INSERT INTO [dbo].[LeaveRecord]" + " ([StaffId]" + " ,[From]" + " ,[To]" + " ,[HalfPeriod]" + " ,[Days]" + " ,[TypeOfLeave])" + " VALUES" + " (@StaffId" + " ,@From" + " ,@To" + " ,@HalfPeriod" + " ,@Days" + " ,@TypeOfLeave)"; } else { sb = "INSERT INTO [dbo].[LeaveRecord]" + " ([StaffId]" + " ,[Days])" + " VALUES" + " (@StaffId" + " ,@Days)"; } using (var cmd = new SqlCommand(sb, conn)) { cmd.Parameters.AddWithValue("@StaffId", model.StaffId); cmd.Parameters.AddWithValue("@Days", model.Days); if (model.From.HasValue && model.To.HasValue) { cmd.Parameters.AddWithValue("@From", model.From); cmd.Parameters.AddWithValue("@To", model.To); cmd.Parameters.AddWithValue("@HalfPeriod", model.HalfPeriod); cmd.Parameters.AddWithValue("@TypeOfLeave", model.TypeOfLeave); } var res = await cmd.ExecuteNonQueryAsync(); if (res > 0) { return(true); } else { return(false); } } }
public LeaveModel GetLeaveByID(int leaveID) { LeaveModel leaveModel = null; tbl_Leaves LeavesOB = (from lv in _dbContext.tbl_Leaves where lv.ID == leaveID select lv ).FirstOrDefault(); leaveModel = _leavesMapper.GetLeaveModelFromLeavesOB(LeavesOB); return(leaveModel); }
//get the details of the leave protected LeaveModel getLeaveInfo() { LeaveModel leaveModel = new LeaveModel(); leaveModel.UserID = UserID; leaveModel.LeaveType = Convert.ToInt32(ddlLeaveType.SelectedValue); leaveModel.FromDate = Convert.ToDateTime(txtFromDate.Text); leaveModel.ToDate = Convert.ToDateTime(txtToDate.Text); leaveModel.Contact = txtContactNo.Text; leaveModel.Reason = txtReason.Text; return(leaveModel); }
public void LeaveChat(string message = "") { var leaveMessage = new LeaveModel() { Nickname = _usernameProvider.GetUsername() }; _publisher.PublishMessage(leaveMessage); if (string.IsNullOrWhiteSpace(message)) { MessageChat(message); } }
public async Task <LeaveModel> UpdateMeAsync(LeaveModel model) { if (model == null) { throw new ArgumentNullException(); } var leave = _leaveMapper.ConvertToDataModel(model); leave = await _leaveRepository.UpdateAsync(leave); return(_leaveMapper.ConvertToModel(leave)); }
public async Task <IActionResult> Edit(int id, [Bind("id,isPaid,startDate,endDate,appicationDate,halfDay")] LeaveModel leaveModel) { if (await extractUser()) { if (id != leaveModel.id) { return(NotFound()); } ModelState.Remove("applicant"); if (ModelState.IsValid) { if (leaveModel.approved == false) { try { LeaveModel UpdatedModel = await _context.Leaves.FirstOrDefaultAsync(l => l.id == id); UpdatedModel.startDate = leaveModel.startDate; UpdatedModel.endDate = leaveModel.endDate; UpdatedModel.isPaid = leaveModel.isPaid; UpdatedModel.halfDay = leaveModel.halfDay; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LeaveModelExists(leaveModel.id)) { return(NotFound()); } else { throw; } } //TODO: da vrushta dr action i viewdata return(RedirectToAction(nameof(IndexDisapproved))); } else { return(View("NoPermission")); } } return(View("~/Views/Holidays/HolidaysPaidUnpaidCRUD/Edit.cshtml", leaveModel)); } else { return(RedirectToAction("Index", "LogIn")); } }
//Appy leave public int ApplyLeave(LeaveModel leaveModel, DataTable dt) { /* * 1: LeaveApplied * 0: Leave Already Exists */ List <SqlParameter> sqUpdate = new List <SqlParameter>(); sqUpdate.Add(new SqlParameter("@UserId", leaveModel.UserID)); sqUpdate.Add(new SqlParameter("@LeaveTypeId", leaveModel.LeaveType)); sqUpdate.Add(new SqlParameter("@ContactNo", leaveModel.Contact)); sqUpdate.Add(new SqlParameter("@Reason", leaveModel.Reason)); sqUpdate.Add(new SqlParameter("@FromDate", leaveModel.FromDate)); sqUpdate.Add(new SqlParameter("@ToDate", leaveModel.ToDate)); DataTable returnCode = DAL.SQLHelp.ExecuteReader("Usp_ApplyLeave", sqUpdate); Int32 LeaveID = Convert.ToInt32(returnCode.Rows[0][0]); Int32 ClientID = Convert.ToInt32(returnCode.Rows[0][1]); Boolean IsPaid = true; Int32 LeaveQuotaUsed = 1; if ((LeaveID != 0) && (ClientID != 0)) { foreach (DataRow row in dt.Rows) { row["ClientId"] = ClientID; row["IsPaid"] = IsPaid; row["LeaveId"] = LeaveID; row["LeaveQuotaUsed"] = LeaveQuotaUsed; } try { DAL.SQLHelp.CopyToServer("Tbl_Attendance_Details", dt); } catch (Exception) { throw; } return(1); } else { return(0); } }
public ActionResult Index() { var leaveParams = new LeaveParamsDTO { PersonalLeaves = 15, SickLeaves = 11 }; var result = _leaveService.GetAnnualLeavesByDepartment(leaveParams, Utility.Enums.Departments.HR); var model = new LeaveModel() { AnnualLeaves = result }; return(View(model)); }
private LeaveModel PrepareLeaveModel(Leave leave) { LeaveModel leaveTemp = new LeaveModel(); leaveTemp.Id = leave.Id; leaveTemp.AddressDuringLeave = leave.AddressDuringLeave; leaveTemp.ContactDuringLeave = leave.ContactDuringLeave; leaveTemp.Date = leave.Date; leaveTemp.EmployeeId = leave.EmployeeId; if (leaveTemp.EmployeeId > 0) { leaveTemp.EmployeeName = leave.Employee.FullName; } leaveTemp.EndDate = leave.EndDate.AddMinutes(timeZoneOffset).ToString("dd MMM yyyy"); leaveTemp.LeaveReason = leave.LeaveReason; leaveTemp.LeaveTypeId = leave.LeaveTypeId; if (leaveTemp.LeaveTypeId > 0) { leaveTemp.LeaveTypeName = leave.LeaveType.Name; } leaveTemp.NoofDays = leave.NoOfDays; leaveTemp.RemovedBy = leave.RemovedBy; leaveTemp.RemovedOn = leave.RemovedOn; leaveTemp.StartDate = leave.StartDate.AddMinutes(timeZoneOffset).ToString("dd MMM yyyy"); leaveTemp.Status = leave.Status; leaveTemp.SchoolId = leave.SchoolId; if (leaveTemp.SchoolId > 0) { leaveTemp.SchoolName = leave.School.Name; leaveTemp.UpazilaId = leave.School.UpazilaId; if (leaveTemp.UpazilaId > 0) { //leaveTemp.UpazilaName = leave.School.Upazila.Name; leaveTemp.DistrictId = leave.School.Upazila.DistrictId; if (leaveTemp.DistrictId > 0) { //leaveTemp.DistrictName = leave.School.Upazila.District.Name; leaveTemp.DivisionId = leave.School.Upazila.District.DivisionId; if (leaveTemp.DivisionId > 0) { //leaveTemp.DivisionName = leave.School.Upazila.District.Division.Name; leaveTemp.GeoName = leave.School.Upazila.District.Division.Name + " - " + leave.School.Upazila.District.Name + " - " + leave.School.Upazila.Name; } } } } return(leaveTemp); }
public async Task <LeaveModel> AddMeAsync(LeaveModel model, int employeeId) { if (model == null) { throw new ArgumentNullException(); } var leave = _leaveMapper.ConvertToDataModel(model); leave.EmployeeId = employeeId; leave.Status = (int)LeaveStatus.Pending; leave = await _leaveRepository.AddAsync(leave); return(_leaveMapper.ConvertToModel(leave)); }