Beispiel #1
0
        public bool RejectRequest(string requestId, string shiftId, string rejectedBy, string responseComment)
        {
            try
            {
                var pending  = EnumHelpers.GetDescription(DayOffRequestStatus.PENDING);
                var rejected = EnumHelpers.GetDescription(DayOffRequestStatus.REJECTED);

                var request = Entities.DayOffRequests.Where(x => x.RequestId.Equals(requestId) && x.Status.Equals(pending)).FirstOrDefault();

                if (request == null)
                {
                    return(false);
                }

                request.ResponseManagerId = rejectedBy;
                request.Status            = rejected;
                request.ResponseComment   = responseComment;

                Entities.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public IList <Employee> GetAllEmployeeToAssignShift(DateTime dateOfShift)
        {
            try
            {
                var approved           = EnumHelpers.GetDescription(VacationRequestStatus.APPROVED);
                var onVacationEmployee = Entities.Employees.Join(Entities.VacationRequests,
                                                                 e => e.EmployeeId, vr => vr.RequestEmployeeId,
                                                                 (e, vr) => new
                {
                    e.EmployeeId,
                    vr.StartDate,
                    vr.EndDate,
                    vr.Status
                })
                                         .Where(x => x.Status.Equals(approved))
                                         .Select(x => x.EmployeeId)
                                         .Distinct()
                                         .ToList();

                return(Entities.Employees.Where(x => !onVacationEmployee.Contains(x.EmployeeId) &&
                                                x.IsDeleted == false).ToList());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public bool ApproveRequest(string requestId, string approvedBy, string responseComment)
        {
            try
            {
                var pending  = EnumHelpers.GetDescription(VacationRequestStatus.PENDING);
                var approved = EnumHelpers.GetDescription(VacationRequestStatus.APPROVED);

                var request = Entities.VacationRequests.Where(x => x.RequestId.Equals(requestId) && x.Status.Equals(pending)).FirstOrDefault();

                if (request == null)
                {
                    return(false);
                }

                request.ResponseManagerId = approvedBy;
                request.Status            = approved;
                request.Comment           = responseComment;

                Entities.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(DependencyProperty.UnsetValue);
            }

            return(EnumHelpers.GetDescription((Enum)value));
        }
Beispiel #5
0
        public override string ToString()
        {
            UriQuery query = new UriQuery(BaseUrl);

            query.Add("api_key", ApiKey);
            query.Add("format", "json");

            if (!string.IsNullOrEmpty(Text))
            {
                query.Add("text", Text);
            }

            if (Bucket.HasValue)
            {
                foreach (var bucket in Bucket.Value.GetBucketDescriptions())
                {
                    query.Add("bucket", bucket);
                }
            }

            if (Limit.HasValue)
            {
                query.Add("limit", Limit.Value);
            }

            if (MaxFamiliarity.HasValue)
            {
                query.Add("max_familiarity", MaxFamiliarity.Value);
            }

            if (MinFamiliarity.HasValue)
            {
                query.Add("min_familiarity", MinFamiliarity.Value);
            }

            if (MaxHotttnesss.HasValue)
            {
                query.Add("max_hotttnesss", MaxHotttnesss.Value);
            }

            if (MinHotttnesss.HasValue)
            {
                query.Add("min_hotttnesss", MinHotttnesss.Value);
            }

            if (Results.HasValue)
            {
                query.Add("results", Results.Value);
            }

            if (Sort.HasValue)
            {
                query.Add("sort", EnumHelpers.GetDescription(Sort.Value));
            }

            return(query.ToString());
        }
Beispiel #6
0
        private async void Connect()
        {
            try
            {
                Error = "";
                IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(Ip), Port);
                ConnectInProgress = true;
                Error             = "Csatlakozás folyamatban...";
                await _client.Connect(endpoint, PlayerName);

                ConnectionStatus = $"Csatlakozva, kapott szín: {EnumHelpers.GetDescription(_client.Player)}\nJátékfázis: {EnumHelpers.GetDescription(_client.GameStage)}";
                Error            = "";
                _playerList.SynchronizeListWithClient();
                SelectedGameStage = _client.GameStage;
                if (SelectedGameStage == GameStage.First)
                {
                    SelectedLayout = ShipLayout.Small;
                }
                else if (SelectedGameStage == GameStage.Second)
                {
                    SelectedLayout = ShipLayout.Medium;
                }
                else
                {
                    LayoutOptions = new ObservableCollection <ShipLayout>()
                    {
                        ShipLayout.BigLong,
                        ShipLayout.BigWide
                    };
                    SelectedLayout = ShipLayout.BigWide;
                }
                OnPropertyChanged(nameof(IsConnected));
            }
            catch (ConnectionRefusedException)
            {
                Error = "A megadott játékhoz már nem lehet csatlakozni.";
            }
            catch (TimeoutException)
            {
                Error = "Nem jött létre a kapcsolat az időlimiten belül.";
            }
            catch (Exception)
            {
                Error = $"A megadott címen nem található játék!";
            }
            finally
            {
                ConnectInProgress = false;
            }
        }
        public IActionResult GetPostsVeiculos([FromQuery] ListPostsInputModel data)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var results = _service.ListPosts(data, GetVirtualPath());

                #region Customization
                var comunications = new List <ComunicationViewModel>();
                foreach (var item in results)
                {
                    var comunication = new ComunicationViewModel(
                        item.title,
                        item.content,
                        item.createdAt
                        );

                    var imageURL = item.files.FirstOrDefault(i => i.session == EnumHelpers.GetDescription(FileSessions.title));
                    comunication.imageURL = imageURL == null ? "" : imageURL.name;

                    var optional = item.files.FirstOrDefault(i => i.session == EnumHelpers.GetDescription(FileSessions.optional));
                    if (optional != null)
                    {
                        var extension = $".{optional.name.Split('.')[optional.name.Split('.').Count() - 1]}";
                        if (TypeExtensions.IsVideoExtension(extension))
                        {
                            comunication.video = optional.name;
                        }
                        else if (TypeExtensions.IsAudioExtension(extension))
                        {
                            comunication.audio = optional.name;
                        }
                    }

                    comunications.Add(comunication);
                }
                #endregion

                return(Ok(comunications));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message.ToString()));
            }
        }
Beispiel #8
0
        public ActionResult Login(AuthorizeUser user, string ReturnUrl)
        {
            try
            {
                var emp = _employeeServices.Login(user.Username, user.Password);

                if (emp == null)
                {
                    ViewBag.Message = "Invalid username/password";
                    return(View("Login"));
                }

                string role = emp.Position;

                if (ReturnUrl.IsNullOrEmpty())
                {
                    if (role.Equals(EnumHelpers.GetDescription(Role.FRONT_TEAM_MEMBER)) || role.Equals(EnumHelpers.GetDescription(Role.PRODUCTION_TEAM_MEMBER)))
                    {
                        ReturnUrl = string.Format("/Shift/EmployeeView?empId={0}", emp.EmployeeId);
                    }
                    else
                    {
                        ReturnUrl = "/Shift";
                    }
                }

                string userData = JsonConvert.SerializeObject(emp);

                FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                    1, emp.EmployeeId,
                    DateTime.Now, DateTime.Now.AddMinutes(30),
                    false, userData
                    );

                string encryptTicket = FormsAuthentication.Encrypt(authTicket);

                HttpCookie userCookie = new HttpCookie("userCookie", encryptTicket);
                Response.Cookies.Add(userCookie);

                //FormsAuthentication.SetAuthCookie(emp.EmployeeId, false);

                return(Redirect(ReturnUrl));
            }catch (Exception ex)
            {
                ViewBag.Message = "An internal error happend. Please try again later.";

                return(View("Login"));
            }
        }
        public ActionResult GetOrganisationDetailsForOrganisation(Guid organisationId)
        {
            if (organisationId != null)
            {
                Organisation organisationDetails = OrganisationHelpers.GetOrganisation(organisationId);

                if (organisationDetails != null)
                {
                    string businessTypeText = EnumHelpers.GetDescription(organisationDetails.BusinessType);
                    return(Json(new { organisationDetails, businessTypeText, success = true }));
                }
                return(Json(new { success = false }));
            }
            return(Json(new { success = false }));
        }
Beispiel #10
0
        public ActionResult GetBranchAddressDetailsForBranch(Guid branchId)
        {
            if (branchId != null)
            {
                Branch branchDetails = BranchHelpers.GetBranch(branchId);

                if (branchDetails != null)
                {
                    string branchBusinessType = EnumHelpers.GetDescription(branchDetails.BusinessType);

                    return(Json(new { branchDetails, branchBusinessType, success = true }));
                }
                return(Json(new { success = false }));
            }
            return(Json(new { success = false }));
        }
Beispiel #11
0
 public bool CreateDayOff(DayOffRequest request)
 {
     try
     {
         return(dayOffRequestRepositories.CreateDayOff(new Repositories.Context.Entities.DayOffRequest
         {
             RequestId = Guid.NewGuid().ToString(),
             RequestedShiftId = request.RequestedShiftId,
             RequestEmployeeId = request.RequestEmployeeId,
             RequestedAt = DateTime.Now,
             Status = EnumHelpers.GetDescription(DayOffRequestStatus.PENDING),
             Reason = request.Reason
         }));
     }catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #12
0
 public bool CreateVacationRequest(VacationRequest request)
 {
     try
     {
         return(vacationRequestRepositories.CreateVacationRequest(new Repositories.Context.Entities.VacationRequest
         {
             RequestId = Guid.NewGuid().ToString(),
             RequestEmployeeId = request.RequestEmployeeId,
             RequestedAt = DateTime.Now,
             Status = EnumHelpers.GetDescription(VacationRequestStatus.PENDING),
             StartDate = request.StartDate,
             EndDate = request.EndDate
         }));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #13
0
 public IList <DTO.Models.DayOffRequest> GetAllPendingRequest()
 {
     try
     {
         var pending = EnumHelpers.GetDescription(DayOffRequestStatus.PENDING);
         return(Entities.DayOffRequests
                .Join(Entities.Employees, dor => dor.RequestEmployeeId, e => e.EmployeeId,
                      (dor, e) => new { dor, e })
                .Join(Entities.Shifts, dor_e => dor_e.dor.RequestedShiftId, s => s.ShiftId,
                      (dor_e, s) => new {
             dor_e.dor.RequestId,
             dor_e.dor.RequestEmployeeId,
             RequestEmployeeName = dor_e.e.FirstName + " " + dor_e.e.LastName,
             dor_e.dor.RequestedShiftId,
             s.StartTime,
             s.EndTime,
             dor_e.dor.RequestedAt,
             dor_e.dor.Reason,
             dor_e.dor.Status
         })
                .Where(x => x.Status.Equals(pending))
                .Select(r => new DTO.Models.DayOffRequest {
             RequestId = r.RequestId,
             RequestEmployeeId = r.RequestEmployeeId,
             RequestEmployeeName = r.RequestEmployeeName,
             RequestedShift = new DTO.Models.Shift {
                 ShiftId = r.RequestedShiftId,
                 StartTime = r.StartTime,
                 EndTime = r.EndTime
             },
             RequestedAt = r.RequestedAt,
             Reason = r.Reason,
             Status = r.Status
         })
                .ToList());
     }catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #14
0
        public ActionResult Create(AddVacationRequestVM request)
        {
            try
            {
                var userInfo        = CookieHelpers.GetUserInfo();
                var vacationRequest = new VacationRequest
                {
                    RequestEmployeeId = userInfo.EmployeeId,
                    RequestedAt       = DateTime.Now,
                    StartDate         = request.StartDate,
                    EndDate           = request.EndDate,
                    Status            = EnumHelpers.GetDescription(VacationRequestStatus.PENDING)
                };

                var isAdded = vacationRequestServices.CreateVacationRequest(vacationRequest);

                return(Json(new BaseViewModel <bool>(true, string.Empty, isAdded), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new BaseViewModel <bool>(true, ex.Message, false), JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Create(AddDayOffRequestVM request)
        {
            try
            {
                var userInfo      = CookieHelpers.GetUserInfo();
                var dayOffRequest = new DayOffRequest
                {
                    RequestedShiftId  = request.ShiftId,
                    RequestEmployeeId = userInfo.EmployeeId,
                    RequestedAt       = DateTime.Now,
                    Reason            = request.Reason,
                    Status            = EnumHelpers.GetDescription(DayOffRequestStatus.PENDING)
                };

                var isAdded = dayOffRequestServices.CreateDayOff(dayOffRequest);

                return(Json(new BaseViewModel <bool>(true, string.Empty, isAdded), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new BaseViewModel <bool>(true, ex.Message, false), JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #16
0
 private static string GetDescription(Enum value)
 {
     return(EnumHelpers.GetDescription(value));
 }
Beispiel #17
0
        // GET: Task
        public ActionResult Details(Guid?userTaskId)
        {
            if (userTaskId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ApplicationDbContext db = new ApplicationDbContext();

            //Get current user for building the Usertaskview of selected record
            AppUser appUser = AppUserHelpers.GetAppUser(db, User);

            //Get UserTaskView of selected UserTask record
            UserTaskView     userTaskView     = null;
            UserTaskFullView userTaskFullView = new UserTaskFullView()
            {
                UserTaskView = userTaskView
            };

            try  //try helps with issues, if no records for example then we are left with null userTaskView instead of error
            {
                userTaskView = UserTaskViewHelpers.GetUserTaskForUserView(db, appUser.AppUserId, userTaskId.Value);

                //Get the requestor appuser details and branch details
                AppUser createdByAppUser = AppUserHelpers.GetAppUser(userTaskView.CreatedBy.AppUserId);
                Branch  createdByAppUserCurrentBranch = BranchHelpers.GetCurrentBranchForUser(db, userTaskView.CreatedBy.AppUserId);

                //If this is a on-hold user then get the current user role
                BranchUser branchUser = null;

                if (userTaskView.AppUserReference != null)
                {
                    branchUser = BranchUserHelpers.GetBranchUser(db, userTaskView.AppUserReference.AppUserId, userTaskView.AppUserReference.CurrentBranchId);
                }

                //Build the view model
                userTaskFullView = new UserTaskFullView();
                userTaskFullView.UserTaskView = userTaskView;
                if (branchUser != null)
                {
                    userTaskFullView.BranchUserUserRole = branchUser.UserRole;
                }
                userTaskFullView.CreatedByAppUser = createdByAppUser;
                userTaskFullView.CreatedByAppUserCurrentBranch = createdByAppUserCurrentBranch;

                if (userTaskView.AppUserReference != null)
                {
                    ViewBag.EntityStatusUserRole = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.UserTaskView.AppUserReference.EntityStatus);
                }
                else
                {
                    ViewBag.EntityStatusUserRole = "";
                }

                if (userTaskView.BranchReference != null)
                {
                    ViewBag.EntityStatusBranchStatus = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.UserTaskView.BranchReference.EntityStatus);
                }
                else
                {
                    ViewBag.EntityStatusBranchStatus = "";
                }

                ViewBag.EntityStatusCreatedByUserRole         = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.CreatedByAppUser.EntityStatus);
                ViewBag.EntityStatusCreatedByUserBranchStatus = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.CreatedByAppUserCurrentBranch.EntityStatus);

                ViewBag.UserTaskUserRole = EnumHelpers.GetDescription((UserRoleEnum)branchUser.UserRole);
            }
            catch { }

            return(View(userTaskFullView));
        }