// GET: ApplicationTypes
        public Object DashboardDisplayPost([FromBody] DashboardDisplay dd)
        {
            string             sJSONResponse  = "";
            DataTable          dt_AppType     = new DataTable();
            string             ServerDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
            int                a = 0;
            string             olPackage_Query = "";
            PaymentDetailsPost Pdetails        = new PaymentDetailsPost();

            try
            {
                cnn.Open();
                olPackage_Query = "insert into DashboardDisplay(DisplayName,Comments,CreatedBy,CreatedOn,IsDeleted,IsActive,ScreenId) values('" + dd.displayName + "','" + dd.comments + "','" + dd.createdBy + "','" + ServerDateTime + "',0,1," + dd.screenId + ") SELECT @@IDENTITY;";
                SqlCommand tm_cmd = new SqlCommand(olPackage_Query, cnn);
                a = Convert.ToInt32(tm_cmd.ExecuteScalar());
                Pdetails.status        = "Success";
                Pdetails.transactionId = a;
            }
            catch (Exception ex)
            {
                Pdetails.status = "Fail";
            }
            finally
            {
                cnn.Close();
            }

            sJSONResponse = JsonConvert.SerializeObject(Pdetails);

            return(sJSONResponse);
        }
        public Object GetDashboardDisplay([FromBody] DashboardDisplay da)
        {
            DashboardDisplayOutput daOP = new DashboardDisplayOutput();
            DataSet SelectedSlots       = new DataSet();
            string  sJSONResponse       = "";

            DataTable dt_Sessions = new DataTable();

            List <DashboardDisplayResponse> dalots = new List <DashboardDisplayResponse>();

            try
            {
                dt_Sessions = getdata(string.Format("select DD.ID,DD.ScreenId,DisplayName,Comments,D.ScreenName from DashboardDisplay DD,Dashboard D where DD.ScreenId=D.ScreenId and DD.IsDeleted=0 and DD.IsActive=1 order by Id asc", ""));

                for (int i = 0; i < dt_Sessions.Rows.Count; i++)
                {
                    DashboardDisplayResponse SlotsDetails = new DashboardDisplayResponse {
                        id = dt_Sessions.Rows[i]["ID"].ToString(), displayName = dt_Sessions.Rows[i]["DisplayName"].ToString(), comments = dt_Sessions.Rows[i]["Comments"].ToString(), screenId = dt_Sessions.Rows[i]["ScreenId"].ToString(), screenName = dt_Sessions.Rows[i]["ScreenName"].ToString()
                    };
                    dalots.Add(SlotsDetails);
                }

                daOP.status   = "success";
                daOP.value    = dalots;
                sJSONResponse = JsonConvert.SerializeObject(daOP);
            }
            catch (Exception ec)
            {
                daOP.status   = "fail";
                sJSONResponse = JsonConvert.SerializeObject(daOP);
            }


            return(sJSONResponse);
        }
        /// <summary>
        /// Created by Thomas Baurnberger
        /// </summary>
        /// <param name="appointment"></param>
        /// <param name="employeeid"></param>
        /// <returns></returns>
        #region Create Methoods

        public string GenerateDashboardDisplay(Appointment appointment, int employeeid)
        {
            DashboardDisplay dashboardDisplay = new DashboardDisplay();

            if ((appointment.Startdate).ToString("d") == (appointment.Enddate).ToString("d"))
            {
                dashboardDisplay.Duration = (appointment.Startdate).ToString();
            }
            else
            {
                dashboardDisplay.Duration = "From " + (appointment.Startdate).ToString("d") + " to " + (appointment.Enddate).ToString("d");;
            }

            dashboardDisplay.Employee            = _unitOfWork.Employees.GetById(employeeid);
            dashboardDisplay.EmployeeId          = employeeid;
            dashboardDisplay.AppointmentId       = appointment.Id;
            dashboardDisplay.Name                = appointment.AppoName;
            dashboardDisplay.SpecificInformation = Convert.ToString(appointment.AppoType);
            dashboardDisplay.Startdatum          = DateTime.Now;

            if (!CreateDashboardDisplay(dashboardDisplay))
            {
                return("Error during the creation of the DashboardDisplay!");
            }
            else
            {
                return(null);
            }
        }
 private void DeleteDashBoardTask(DashboardDisplay dashboardDisplay)
 {
     try
     {
         _unitOfWork.DashboardDisplays.Delete(dashboardDisplay);
         _unitOfWork.Save();
     }
     catch (Exception ex)
     {
     }
 }
 public bool CreateDashboardDisplay(DashboardDisplay dashboardDisplay)
 {
     try
     {
         _unitOfWork.DashboardDisplays.Add(dashboardDisplay);
         _unitOfWork.Save();
         return(true);
     }
     catch (ValidationException ex)
     {
         return(false);
     }
 }
        public IActionResult DeleteAppointment(int employeeId, int appointmentId, string buttonClicked, string priorityButton)
        {
            DashboardDisplay dashboardDisplay = _unitOfWork.DashboardDisplays.GetByEmployeeIdAndAppointmentId(employeeId, appointmentId);

            this.DeleteDashBoardTask(dashboardDisplay);
            _unitOfWork.Save();

            return(RedirectToAction(nameof(Feed), new
            {
                employeeId = employeeId,
                buttonClicked = buttonClicked,
                priority = IsPriorityButtonClicked(priorityButton)
            }));
        }
        private bool SetUpForDashboardDisplay(EmployeeTask employeeTask)
        {
            DashboardDisplay dashboardDisplay = GenerateDashboardTask(employeeTask);

            if (CreateDashboardDisplay(dashboardDisplay))
            {
                employeeTask.Task.Status = Core.Enum.TaskStatusType.Processing;

                return(UpdateTask(employeeTask.Task));
            }
            else
            {
                return(false);
            }
        }
        private DashboardDisplay GenerateDashboardTask(EmployeeTask employeeTask)
        {
            DashboardDisplay dashboardTask = new DashboardDisplay();
            string           endDate;

            if (employeeTask.Task.Deadline == null)
            {
                endDate = " open end";
            }
            else
            {
                endDate = " End: " + ((DateTime)(employeeTask.Task.Deadline)).ToString("d");
            }

            dashboardTask.Name                = employeeTask.Task.TaskName;
            dashboardTask.Startdatum          = DateTime.Now;
            dashboardTask.SpecificInformation = "Priority: " + Convert.ToString(employeeTask.Task.Priority);
            dashboardTask.Duration            = "Start: " + (dashboardTask.Startdatum).ToString("d") + endDate;
            dashboardTask.Employee            = employeeTask.Employee;
            dashboardTask.EmployeeId          = employeeTask.Employee.Id;
            dashboardTask.TaskId              = employeeTask.Task.Id;

            return(dashboardTask);
        }
        public Object DashboardDisplayDelete([FromBody] DashboardDisplay dd)
        {
            SqlCommand command        = cnn.CreateCommand();
            string     ServerDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);

            try
            {
                cnn.Close();
                cnn.Open();
                SqlTransaction transaction;
                transaction         = cnn.BeginTransaction("SampleTransaction");
                command.Connection  = cnn;
                command.Transaction = transaction;
                try
                {
                    command.CommandText = "delete from DashboardDisplay where Id='" + dd.Id + "' ";
                    command.ExecuteNonQuery();

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                }
                finally
                {
                }
            }
            catch (Exception ec)
            {
            }

            string sJSONResponse = "";

            return(sJSONResponse);
        }
        public bool CheckButtons(IUnitOfWork uow, int employeeId, int taskId, EmployeesFinishOrPassViewModel model)
        {
            Task editTask = model.Task; EmployeeTask employeeTask = _unitOfWork.EmployeeTasks.GetByEmployeeIdAndTaskId(employeeId, taskId);

            if (model.Pass != null)
            {
                if (model.PassConfirmed == true)
                {
                    if (model.RecipientEmployee != null)
                    {
                        model.RecipientEmployee = _unitOfWork.Employees.GetById(model.RecipientEmployee.Id);

                        DashboardDisplay dashboardDisplay = _unitOfWork.DashboardDisplays.GetByEmployeeIdAndTaskId(employeeId, taskId);
                        DeleteDashBoardTask(dashboardDisplay);

                        employeeTask.PassedTask = model.RecipientEmployee;
                        UpdateEmployeeTask(employeeTask);

                        EmployeeTask recipientEmployeeTask = _unitOfWork.EmployeeTasks.GetByEmployeeIdAndTaskId(model.RecipientEmployee.Id, taskId);

                        if (model.FixedTask == false)
                        {
                            if (recipientEmployeeTask == null)
                            {
                                recipientEmployeeTask        = GenerateEmployeetask(model.RecipientEmployee.Id, taskId);
                                recipientEmployeeTask.Picked = false;
                                CreateEmployeeTask(recipientEmployeeTask);
                            }
                            else
                            {
                                recipientEmployeeTask.Picked = false;
                                UpdateEmployeeTask(recipientEmployeeTask);
                            }

                            recipientEmployeeTask.Task.Status = Core.Enum.TaskStatusType.Open;
                        }
                        else
                        {
                            if (recipientEmployeeTask == null)
                            {
                                recipientEmployeeTask        = GenerateEmployeetask(model.RecipientEmployee.Id, taskId);
                                recipientEmployeeTask.Picked = true;
                                CreateEmployeeTask(recipientEmployeeTask);
                            }
                            else
                            {
                                recipientEmployeeTask.Picked = true;
                                UpdateEmployeeTask(recipientEmployeeTask);
                            }

                            DashboardDisplay recipientDashboardDisplay = GenerateDashboardTask(recipientEmployeeTask);
                            CreateDashboardDisplay(recipientDashboardDisplay);
                        }

                        recipientEmployeeTask.Task.Information = model.Task.Information;
                        recipientEmployeeTask.Task.Priority    = model.Task.Priority;
                        recipientEmployeeTask.Task.ValuedTime  = model.Task.ValuedTime;
                        UpdateTask(recipientEmployeeTask.Task);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    model.PassClicked = true;
                    model.LoadSelectList(uow, employeeId, taskId);
                }
            }
            else if (model.Finish != null)
            {
                if (model.FinishConfirmed == true)
                {
                    DashboardDisplay dashboardDisplay = _unitOfWork.DashboardDisplays.GetByEmployeeIdAndTaskId(employeeId, taskId);
                    DeleteDashBoardTask(dashboardDisplay);

                    employeeTask.Task.Status  = Core.Enum.TaskStatusType.Completed;
                    employeeTask.Task.Enddate = DateTime.Now;
                    UpdateTask(employeeTask.Task);
                }
                else
                {
                    model.FinishClicked = true;
                }
            }

            return(true);
        }
 public void Update(DashboardDisplay feedDisplay)
 {
     _dbContext.DashboardDisplay.Update(feedDisplay);
 }
 public void Delete(DashboardDisplay feedDisplay)
 {
     _dbContext.DashboardDisplay.Remove(feedDisplay);
 }
 public void Add(DashboardDisplay feedDisplay)
 {
     _dbContext.DashboardDisplay.Add(feedDisplay);
 }