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

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(supervisors);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SupervisorsExists(supervisors.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(supervisors));
        }
Exemplo n.º 2
0
        private async Task loadBuildingUsers()
        {
            try
            {
                var bUsers = await _buildingService.GetBuildingUsers(BuildingId, false);

                List <BuildingUser> users = (List <BuildingUser>)bUsers;
                if (users != null && users.Count > 0)
                {
                    for (var i = 0; i < users.Count; i++)
                    {
                        if (users[i].UserPrivileges.Contains("CN"))
                        {
                            Contractors.Add(users[i]);
                        }
                        if (users[i].UserPrivileges.Contains("ES"))
                        {
                            Supervisors.Add(users[i]);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                //Dialogs.ShowError(e?.Message);
            }
        }
Exemplo n.º 3
0
 public DefaultSupervisorOverridePluginConfiguration WithSupervisor(
     string stageName,
     string supervisorName,
     Type?supervisorClass)
 {
     Supervisors.Add(new ConfiguredSupervisor(stageName, supervisorName, supervisorClass));
     return(this);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Inicia el proceso de autenticación de un supervisor (usuario BackOffice)
        /// </summary>
        /// <param name="data">Modelo con los datos necesarios para la autenticación.</param>
        /// <returns>
        /// Modelo <see cref="PostBOSigninResponseModel"/> con los datos de la respuesta.
        /// </returns>
        /// <exception cref="ArgumentNullException">El parámetro 'data' no puede ser NULL.</exception>
        public PostBOSigninResponseModel Signin(PostBOSigninRequestModel data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("El parámetro 'data' no puede ser NULL.");
            }

            var signinModel = new PostBOSigninResponseModel
            {
                status = ResultStatus.ACCESS_DENIED
            };

            try
            {
                Supervisors supervisor = _supervisorRepository.SingleOrDefault(item => item.Email == data.user);
                if (supervisor == null)
                {
                    signinModel.status = ResultStatus.NOT_FOUND;
                    return(signinModel);
                }

                // validacion de password y estado de aprobacion
                var inHash = CreateHash(data.password);
                var dbHash = supervisor.Password;
                if (inHash != dbHash || supervisor.State == (int)SupervisorState.Pending)
                {
                    return(signinModel);
                }

                signinModel.status      = ResultStatus.SUCCESS;
                signinModel.accessToken = GenerateToken(supervisor.Email, supervisor.State.ToString());
                InsertLogSignIn(supervisor, signinModel);
            }
            catch (ArgumentNullException e)
            {
                return(new PostBOSigninResponseModel
                {
                    status = ResultStatus.ERROR
                });
            }
            catch (ArgumentException e)
            {
                return(new PostBOSigninResponseModel
                {
                    status = ResultStatus.ERROR
                });
            }
            catch (Exception e)
            {
                return(new PostBOSigninResponseModel
                {
                    status = ResultStatus.ERROR
                });
            }

            return(signinModel);
        }
 public CommonSupervisorsPluginConfiguration WithSupervisor(
     string stageName,
     string supervisorName,
     Type supervisedProtocol,
     Type supervisorClass)
 {
     Supervisors.Add(new ConfiguredSupervisor(stageName, supervisorName, supervisedProtocol, supervisorClass));
     return(this);
 }
        public async Task <IActionResult> Create([Bind("Id,SupervisorName")] Supervisors supervisors)
        {
            if (ModelState.IsValid)
            {
                _context.Add(supervisors);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(supervisors));
        }
        /// <summary>
        ///     On Page load method clears or fills form
        /// </summary>
        /// <param name="o">Leave it empty</param>
        private async void OnPageLoad(object o)
        {
            await Initialize();

            if (Id != null)
            {
                TitleText = "Edytuj Pracownika";
                Employee  = await _employeeProxy.GetEmployee((int)Id);

                Id                     = Employee.Id;
                Name                   = Employee.Name;
                Surname                = Employee.Surname;
                Street                 = Employee.Street;
                HouseNumber            = Employee.HouseNumber;
                ApartmentNumber        = Employee.ApartmentNumber;
                City                   = Employee.City;
                PostalCode             = Employee.PostalCode;
                PhoneNumber            = Employee.PhoneNumber;
                IcePhoneNumber         = Employee.IcePhoneNumber;
                Email                  = Employee.Email;
                IdentityCardNumber     = Employee.IdentityCardNumber;
                PersonalIdentityNumber = Employee.PersonalIdentityNumber;
                SportType              = SportTypes.FirstOrDefault(s => s.Id == Employee.SportTypes[0].Id);
                Position               = Positions.FirstOrDefault(p => p.Id == Employee.Position.Id);
                Supervisor             = Supervisors.FirstOrDefault(s => s.Id == Employee.SupervisorId);
                Description            = Employee.Description;
                Password               = Employee.Password;
            }
            else
            {
                TitleText              = "Stwórz Pracownika";
                Id                     = null;
                Name                   = null;
                Surname                = null;
                Street                 = null;
                HouseNumber            = null;
                ApartmentNumber        = null;
                City                   = null;
                PostalCode             = null;
                PhoneNumber            = null;
                IcePhoneNumber         = null;
                Email                  = null;
                IdentityCardNumber     = null;
                PersonalIdentityNumber = null;
                SportType              = null;
                Position               = null;
                Supervisor             = null;
                Description            = null;
                Password               = null;
            }
        }
Exemplo n.º 8
0
        public void InsertLogSignIn(Supervisors supervisor, PostBOSigninResponseModel signinModel)
        {
            if (supervisor != null)
            {
                DateTime dtNow = DateTime.UtcNow;

                LogsGenerals LogPetition = new LogsGenerals
                {
                    TypeLog     = "Log De Peticion Supervisor",
                    Description = "Inicio De Sesion",
                    HourLog     = dtNow,
                    UserId      = supervisor.Id,
                    CallsId     = null
                };
                _logsRepository.Insert(LogPetition);
                _logsRepository.Save();
            }
            else if (supervisor == null)
            {
                DateTime dtNow = DateTime.UtcNow;

                LogsGenerals LogPetition = new LogsGenerals
                {
                    TypeLog     = "Log De Respuesta Supervisor",
                    Description = "No se encuentra registrado",
                    HourLog     = dtNow,
                    UserId      = null,
                    CallsId     = null
                };
                _logsRepository.Insert(LogPetition);
                _logsRepository.Save();
            }
            else if (signinModel.status == ResultStatus.SUCCESS)
            {
                DateTime dtNow = DateTime.UtcNow;

                LogsGenerals LogPetition = new LogsGenerals
                {
                    TypeLog     = "Log De Respuesta",
                    Description = "Inico De Sesion Exitoso",
                    HourLog     = dtNow,
                    UserId      = supervisor.Id,
                    CallsId     = null
                };
                _logsRepository.Insert(LogPetition);
                _logsRepository.Save();
            }
        }
        private List <Supervisors> ReadTables(DataTable dataTable)
        {
            List <Supervisors> activities = new List <Supervisors>();

            foreach (DataRow dr in dataTable.Rows)
            {
                Supervisors super = new Supervisors()
                {
                    Supervisor_ID = (int)dr["Supervisor_ID"],
                    FirstName     = (String)dr["FirstName"],
                    LastName      = (String)dr["LastName"]
                };
                activities.Add(super);
            }
            return(activities);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Crea un supervisor en el sistema.
        /// </summary>
        /// <param name="supervisorData">Datos del supervisor a crear.</param>
        /// <returns>
        /// Modelo <see cref="PostBOSupervisorResponseModel"/> con los datos de la respuesta.
        /// </returns>
        public PostBOSupervisorResponseModel CreateSupervisor(PostBOSupervisorRequestModel supervisorData)
        {
            PostBOSupervisorResponseModel result = new PostBOSupervisorResponseModel
            {
                Status = ResultStatus.ERROR
            };

            var context = _supervisorRepository.GetContext();

            using (var dbTransaction = context.Database.BeginTransaction())
            {
                try
                {
                    var toInsert = new Supervisors()
                    {
                        Name     = supervisorData.Name,
                        Email    = supervisorData.Email,
                        Password = CreateHash(supervisorData.Password),
                        State    = 0
                    };

                    // Se da de alta en BD
                    _supervisorRepository.Insert(toInsert);
                    _supervisorRepository.Save();

                    dbTransaction.Commit();
                    result.Status = ResultStatus.SUCCESS;
                    return(result);
                }
                catch (DbUpdateException updEx)
                {
                    dbTransaction.Rollback();

                    SqlException sqlEx = updEx.GetBaseException() as SqlException;
                    if (sqlEx != null)
                    {
                        switch (sqlEx.Number)
                        {
                        case 515: // NOT NULL values
                            // Determino nombre de la columna que no acepta valor NULL
                            // EJ: "Cannot insert the value NULL into column 'SiebelId', table 'InConcert.dbo.Commercials'."
                            int    indexStart = sqlEx.Message.IndexOf("'", 0) + 1;
                            int    indexEnd   = sqlEx.Message.IndexOf("'", indexStart);
                            string columName  = sqlEx.Message[indexStart..indexEnd];
Exemplo n.º 11
0
 public void Update(Supervisors supervisorold, Supervisors newSup)
 {
     _ctx.Entry(supervisorold).CurrentValues.SetValues(newSup);
 }
Exemplo n.º 12
0
 public void Insert(Supervisors supervisor)
 {
     _ctx.Supervisors.Add(supervisor);
 }
Exemplo n.º 13
0
        public override async Task InitializeAsync(object navigationData)
        {
            MessagingCenter.Subscribe <BasicInfoPage, string>(this, MessengerCenterMessages.ChangeTitleOnCertificateTab, (details, s) =>
            {
                Title = s;
            });
            MessagingCenter.Subscribe <AssociatedBoardsPage, string>(this, MessengerCenterMessages.ChangeTitleOnCertificateTab, (details, s) =>
            {
                Title = s;
            });
            MessagingCenter.Subscribe <EditPointPage, string>(this, MessengerCenterMessages.ChangeTitleOnCertificateTab, (details, s) =>
            {
                Title = s;
            });

            var certId = navigationData as string;

            if (certId != null)
            {
                _certId = certId;
            }

            try
            {
                using (var dlg = this.Dialogs.Loading("Progress (No Cancel)"))
                {
                    var certResult = await _certificatesService.GetCertificateDetails(BuildingId, _certId);

                    if (!certResult.Success)
                    {
                        Dialogs.Toast(certResult.Message);
                        return;
                    }

                    var cert = certResult.ResultObject as EditCertificate;

                    if (cert != null)
                    {
                        await loadBuildingUsers();

                        var amendDates = await _lookupsService.GetBsAmendmentDates(false);

                        List <BsAmendmentDates> bsAmendmentDates = (List <BsAmendmentDates>)amendDates;

                        BasicInfoViewModel.Certificate        = cert.CertificateBasicInfo;
                        BasicInfoViewModel.Contractors        = Contractors;
                        BasicInfoViewModel.SelectedContractor = Contractors.FirstOrDefault(x => x.UserId == cert.CertificateBasicInfo.ConUserId);
                        //BasicInfoViewModel.RaisePropertyChanged(() => SelectedContractor);

                        BasicInfoViewModel.Supervisors        = Supervisors;
                        BasicInfoViewModel.SelectedSupervisor = Supervisors.FirstOrDefault(x => x.UserId == cert.CertificateBasicInfo.EsUserId);
                        //BasicInfoViewModel.RaisePropertyChanged(() => SelectedSupervisor);

                        BasicInfoViewModel.BsAmendmentDates        = bsAmendmentDates;
                        BasicInfoViewModel.SelectedBsAmendmentDate = bsAmendmentDates.FirstOrDefault(x => x.CertDateAmended == cert.CertificateBasicInfo.CertDateAmended);
                        //BasicInfoViewModel.RaisePropertyChanged(() => SelectedBsAmendmentDate);

                        AssociatedBoardsViewModel.AssociatedBoards.AddRange(cert.CertificateAssociatedBoards
                                                                            .BoardTests);

                        foreach (var board in cert.CertificateAssociatedBoards.BoardTests)
                        {
                            await _boardsService.GetBoardDetails(board.BoardId, BuildingId);
                        }
                    }

                    await EditPointViewModel.InitializeAsync(null);
                }
            }
            catch (ServiceAuthenticationException e)
            {
                var result = await TryToLogin();

                if (!result)
                {
                    await NavigationService.NavigateToAsync <LoginViewModel>();
                }
                else
                {
                    await InitializeAsync(navigationData);
                }
            }
            catch (Exception e)
            {
                await ShowErrorAlert(e.Message);
            }
        }