public async Task <IActionResult> Edit(int id, [Bind("Id,EmployeeId,LeaveTypeId,IsPaid,IsApproved,DateFiled,Start,End,Hours,Remarks,Attachment,ApprovedBy")] UserLeaves userLeaves)
        {
            if (id != userLeaves.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userLeaves);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserLeavesExists(userLeaves.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"]  = new SelectList(_context.Employee, "Id", "Lastname", userLeaves.EmployeeId);
            ViewData["LeaveTypeId"] = new SelectList(_context.LeaveTypes, "Id", "Title", userLeaves.LeaveTypeId);
            return(View(userLeaves));
        }
Beispiel #2
0
        internal void Register()
        {
            var type = GetType();

            foreach (var member in type.GetMembers())
            {
                foreach (object attribute in member.GetCustomAttributes(true))
                {
                    if (attribute is OnCommandAttribute)
                    {
                        if (member is MethodInfo)
                        {
                            Commands.Add(new MethodCommandTrigger <T>(this, attribute as OnCommandAttribute, member as MethodInfo));
                        }
                        else if (member is PropertyInfo)
                        {
                            Commands.Add(new PropertyCommandTrigger <T>(this, attribute as OnCommandAttribute, member as PropertyInfo));
                        }
                    }
                    else if (attribute is OnUserJoinAttribute)
                    {
                        if (member is MethodInfo)
                        {
                            UserJoins.Add(new UserJoinTrigger <T>(this, member as MethodInfo));
                        }
                    }
                    else if (attribute is OnUserLeaveAttribute)
                    {
                        if (member is MethodInfo)
                        {
                            UserLeaves.Add(new UserLeaveTrigger <T>(this, member as MethodInfo));
                        }
                    }
                    else if (attribute is PreCommandAttribute)
                    {
                        if (member is MethodInfo)
                        {
                            PreCommands.Add(new MethodPreCommandTrigger <T>(this, attribute as PreCommandAttribute, member as MethodInfo));
                        }
                        else if (member is PropertyInfo)
                        {
                            PreCommands.Add(new PropertyPreCommandTrigger <T>(this, attribute as PreCommandAttribute, member as PropertyInfo));
                        }
                    }
                }
            }
        }
Beispiel #3
0
        private bool PlayerLeave(Match match)
        {
            var playerId   = match.Groups[3].Value;
            var playerName = match.Groups[4].Value;
            var reason     = match.Groups[5].Value;

            var user = Users.Where(u => u.Name == playerName).FirstOrDefault();

            if (user == null)
            {
                return(false);
            }                                   //How'd that happen?

            UserLeaves.InvokeSafe(this, new UserEventArgs(user));

            Users.Remove(user);

            return(false);
        }
        public async Task <IActionResult> Create([Bind("Id,EmployeeId,LeaveTypeId,IsPaid,IsApproved,DateFiled,Start,End,Hours,Remarks,Attachment,ApprovedBy")] UserLeaves userLeaves)
        {
            if (ModelState.IsValid)
            {
                userLeaves.DateFiled = DateTime.Now;

                TimeSpan?ts = userLeaves.End - userLeaves.Start;
                userLeaves.Hours      = (decimal)ts.Value.TotalHours;
                userLeaves.IsApproved = false;


                _context.Add(userLeaves);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"]  = new SelectList(_context.Employee, "Id", "Lastname", userLeaves.EmployeeId);
            ViewData["LeaveTypeId"] = new SelectList(_context.LeaveTypes, "Id", "Title", userLeaves.LeaveTypeId);
            return(View(userLeaves));
        }
Beispiel #5
0
 internal void HandeUserLeft(object sender, IrcChannelUserEventArgs e)
 {
     destination = e.GetDestination();
     UserLeaves.ForEach(leave => leave.Handle(e));
     destination = null;
 }