public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] ApprovalLevel approvalLevel)
        {
            if (id != approvalLevel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(approvalLevel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ApprovalLevelExists(approvalLevel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(approvalLevel));
        }
예제 #2
0
        protected void dgApprovalLevel_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "AddNew")
            {
                try
                {
                    ApprovalLevel approvallevel    = new ApprovalLevel();
                    DropDownList  ddlFPositionName = e.Item.FindControl("ddlFPosition") as DropDownList;
                    approvallevel.EmployeePosition = _presenter.GetEmployeePosition(Convert.ToInt32(ddlFPositionName.SelectedValue));
                    DropDownList ddlFWill = e.Item.FindControl("ddlFWill") as DropDownList;
                    approvallevel.Will = ddlFWill.SelectedValue;

                    approvallevel.WorkflowLevel   = _presenter.CurrentApprovalSetting.GetApprovalLevelCount() + 1;
                    approvallevel.ApprovalSetting = _approvalsetting;

                    _presenter.CurrentApprovalSetting.ApprovalLevels.Add(approvallevel);

                    Master.ShowMessage(new AppMessage("Approval Level added successfully.", RMessageType.Info));
                    dgApprovalLevel.EditItemIndex = -1;
                    BindApprovalLevels();
                }
                catch (Exception ex)
                {
                    Master.ShowMessage(new AppMessage("Error: Unable to Add Approval Level. " + ex.Message, RMessageType.Error));
                }
            }
        }
예제 #3
0
 public Expense(DateTime date, Category category, string descrition, decimal amount,
                bool approvalStatus, ApprovalLevel approvalLevel)
 {
     Date           = date;
     Category       = category;
     Description    = descrition;
     Amount         = amount;
     ApprovalStatus = approvalStatus;
     ApprovalLevel  = approvalLevel;
 }
예제 #4
0
    public void UpdateInterface(float desire, ApprovalLevel dad, ApprovalLevel craig, float happiness, int week)
    {
        desireBar.value    = desire;
        happinessBar.value = happiness;

        //Change the sprites based on the Approval Level
        dadApproval.sprite   = ChangeApprovalFace(dad);
        craigApproval.sprite = ChangeApprovalFace(craig);

        weekText.text = "Week " + week;
    }
        public async Task <IActionResult> Create([Bind("Id,Name")] ApprovalLevel approvalLevel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(approvalLevel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(approvalLevel));
        }
예제 #6
0
    private Sprite ChangeApprovalFace(ApprovalLevel lvl)
    {
        switch (lvl)
        {
        case ApprovalLevel.Happy:
            return(approvalHappy);

        case ApprovalLevel.Neutral:
            return(approvalNeutral);

        case ApprovalLevel.Angry:
            return(approvalAngry);
        }

        //We should never get here
        return(approvalNeutral);
    }
예제 #7
0
        private CardAccess CreateCardAccess(ApprovalLevel approvalLevel, string employeeId, string cardId, string doorId, string note, string timeZoneId)
        {
            var res = Db.CardAccesses.FirstOrDefault(ca =>
                                                     ca.CardId == cardId &&
                                                     ca.DoorId == doorId &&
                                                     ca.ApprovalLevel == approvalLevel &&
                                                     ca.ApprovalStatus == ApprovalStatus.WaitingForApproval &&
                                                     ca.AssignmentType == AssignmentType.Special &&
                                                     ca.TimeZoneId == timeZoneId
                                                     )
                      ?? new CardAccess
            {
                CardId         = cardId,
                DoorId         = doorId,
                ApprovalLevel  = approvalLevel,
                ApprovalStatus = ApprovalStatus.WaitingForApproval,
                AssignmentType = AssignmentType.Special,
                TimeZoneId     = timeZoneId
            };

            res.Note             = note;
            res.ApprovedDate     = null;
            res.OriginApproverId = employeeId;

/*
 *          var accessor = Db.Employees.Find(employeeId);
 *          if (accessor != null
 *              && accessor.DelegateToId != null
 *              && (accessor.DelegateFromDate ?? DateTime.MinValue) <= DateTime.Now
 *              && (accessor.DelegateToDate ?? DateTime.MaxValue) >= DateTime.Now)
 *          {
 *              res.ApprovedById = accessor.DelegateToId;
 *          }
 *          else
 *          {
 *              res.ApprovedById = employeeId;
 *          }
 */
            res.ApprovedById = employeeId;
            if (res.Id == null)
            {
                Db.CardAccesses.Add(res);
            }
            return(res);
        }
예제 #8
0
        // metodo che crea una spesa a partire da una riga del file
        // -- analizza il contenuto della riga
        // -- definisce approval level sulla base dell'importo
        // -- definisce approval status sulla base di approval level
        // -- restituisce una Expense
        public static Expense CreateExpenseFromFile(string line)
        {
            // manipolazione della riga e sua analisi
            string[] values = line.Split(";");

            DateTime date = new DateTime(2020, 02, 02); // valore arbitrario

            if (DateTime.TryParse(values[0], out DateTime d))
            {
                date = d;
            }

            Category category = Category.Other; // valore arbitrario

            if (Category.TryParse(values[1], out Category c))
            {
                category = c;
            }

            string description = values[2];

            decimal amount = 0; // valore arbitrario

            if (decimal.TryParse(values[3], out decimal a))
            {
                amount = a;
            }

            var manager = SetExpenseChain(); // primo elemento della catena

            ApprovalLevel approvalLevel = manager.Handle(amount);

            bool approvalStatus = false;

            if (approvalLevel != ApprovalLevel.None)
            {
                approvalStatus = true;
            }

            // **************** qui avrei dovuto creare solo se approvalLevel era true ********************
            // creazione di una Expense
            return(new Expense(date, category, description, amount, approvalStatus, approvalLevel));
        }
예제 #9
0
        protected void dgApprovalLevel_UpdateCommand1(object source, DataGridCommandEventArgs e)
        {
            int           id            = (int)dgApprovalLevel.DataKeys[e.Item.ItemIndex];
            ApprovalLevel approvalLevel = _presenter.CurrentApprovalSetting.GetApprovalLevel(id);

            try
            {
                DropDownList ddlPositionName = e.Item.FindControl("ddlPosition") as DropDownList;
                approvalLevel.EmployeePosition = _presenter.GetEmployeePosition(Convert.ToInt32(ddlPositionName.SelectedValue));
                DropDownList ddlWill = e.Item.FindControl("ddlWill") as DropDownList;
                approvalLevel.Will = ddlWill.SelectedValue;
                // approvalLevel.ApprovalSetting = _approvalsetting;
                _presenter.SaveOrUpdateApprovalSetting(_presenter.CurrentApprovalSetting);
                Master.ShowMessage(new AppMessage("Approval Level  Updated successfully.", Chai.WorkflowManagment.Enums.RMessageType.Info));
                dgApprovalLevel.EditItemIndex = -1;
                BindApprovalLevels();
            }
            catch (Exception ex)
            {
                Master.ShowMessage(new AppMessage("Error: Unable to Update Approval Level Detail. " + ex.Message, Chai.WorkflowManagment.Enums.RMessageType.Error));
            }
        }
예제 #10
0
 public void DeleteApprovalLevel(ApprovalLevel approvallevel)
 {
     _controller.DeleteEntity(approvallevel);
 }