private void InitUserSession() { try { _SessionData = new UserDataSession() { UserName = User.Identity.Name, }; DataMapping.Entities.UserProfile user = UserProfilesLogic.GetUserByUserName(User.Identity.Name); _SessionData.UserId = user.UserId; _SessionData.profileImageUrl = user.ProfilePictureUrl; if (Roles.IsUserInRole("Admin")) { _SessionData.UserRole = UserRoles.Admin; } else if (Roles.IsUserInRole("Employee")) { _SessionData.UserRole = UserRoles.Employee; } Session["UserSession"] = _SessionData; } catch (Exception e) { LogsLogic.InsertLog(new Log() { Message = e.Message, StackTrace = e.StackTrace, StoryName = "ManagementProject/Base/InitUserSession" }); } }
public ActionResult EditProfile(UserProfile model, FormCollection collection) { try { if (ModelState.IsValid) { int day = Int16.Parse(collection["day"]); int month = Int16.Parse(collection["month"]); int year = Int16.Parse(collection["year"]); model.BirthDate = new DateTime(year, month, day); model.ProfilePictureUrl = SessionData.ImgUrl; UserProfilesLogic.UpdateUserProfile(model); SessionData.profileImageUrl = model.ProfilePictureUrl; SessionData.ImgUrl = null; return(RedirectToAction("Index", "Home")); } model = UserProfilesLogic.GetUserByUserName(SessionData.UserName); } catch (Exception e) { LogsLogic.InsertLog(new Log() { Message = e.Message, StackTrace = e.StackTrace, StoryName = "ManagmentProject/Profile/EditProfile(Post)", Parameters = "UserProfile=" + new JavaScriptSerializer().Serialize(model) + "&Collection=" + new JavaScriptSerializer().Serialize(collection) }); } return(View(model)); }
public ActionResult EditProfile() { UserProfile model = new UserProfile(); try { model = UserProfilesLogic.GetUserByUserName(SessionData.UserName); } catch (Exception e) { LogsLogic.InsertLog(new Log() { Message = e.Message, StackTrace = e.StackTrace, StoryName = "ManagmentProject/Profile/EditProfile" }); } return(View(model)); }
public ActionResult Create(int?roleId) { int roleID = roleId ?? 0; EmployeeUsersDetails model = new EmployeeUsersDetails(); try { model = UserProfilesLogic.GetCreateModel(roleID); } catch (Exception e) { LogsLogic.InsertLog(new Log() { Message = e.Message, StackTrace = e.StackTrace, StoryName = "ManagmentProject/Users/Create" }); } return(View(model)); }
public JsonResult GetUserNames(string term, int projectId) { List <string> UsersNames = new List <string>(); try { UsersNames = UserProfilesLogic.GetUserNamesNotInProjectByTerm(term, projectId); } catch (Exception e) { LogsLogic.InsertLog(new Log() { Message = e.Message, StackTrace = e.StackTrace, StoryName = "ManagementProject/UserProjects/GetUserNames", Parameters = "term= " + term }); } return(Json(UsersNames, JsonRequestBehavior.AllowGet)); }
public ActionResult EmployeeAttendence(int userId) { DateTime today = DateTimeHelper.Today(); DateTime firstDay = new DateTime(today.Year, today.Month, 1); List <Attendance> userAttendances = AttendancesLogic.GetAllUserAttendencesBetweenTwoDates(userId, firstDay, today); int totalWorkingDaysInMonth = DateTimeHelper.GetWorkingDaysCountInMonth(firstDay, today); int totalUserWorkingDays = userAttendances.Count; UserProfile user = UserProfilesLogic.GetUserById(userId); UserAttendancesModel model = new UserAttendancesModel { TotalWorkingDaysInMonth = totalWorkingDaysInMonth, TotalUserWorkingDays = totalUserWorkingDays, TotalUserAbsenceDays = (totalWorkingDaysInMonth - totalUserWorkingDays), TotalUserWorkingHours = Math.Round(AttendancesLogic.GetTotalUserWorkingHoursInMonth(userId, firstDay, today), 2), UserAttendances = userAttendances, FirstName = user.FirstName, LastName = user.LastName }; return(View(model)); }
public ActionResult MonthlyStandUpMeetings(int userId) { StandUpMeetingMonthlyHistoryModel model = new StandUpMeetingMonthlyHistoryModel(); try { UserProfile user = UserProfilesLogic.GetUserById(userId); model.StandUpMeetingDetailsList = StandUpMeetingsLogic.GetStandUpMeetingList(userId); model.FirstName = user.FirstName; model.LastName = user.LastName; } catch (Exception e) { LogsLogic.InsertLog(new Log() { Message = e.Message, StackTrace = e.StackTrace, StoryName = "ManagementProject/StandUpMeeting/MonthlyStandUpMeetings" }); } return(View(model)); }