Esempio n. 1
0
 public bool InsertUpdateJobTile(JobTitleModel jobTitle)
 {
     using (var connection = new SqlConnection(connectionString))
     {
         try
         {
             SqlParameter[] parameters = new SqlParameter[] {
             new SqlParameter("@JobTitleId",jobTitle.JobTitleId),
             new SqlParameter("@JobTitleName",jobTitle.JobTitleName),
             new SqlParameter("@UpdatedBy",jobTitle.UpdatedBy),
             };
             var data =
                 SqlHelper.ExecuteNonQuery
                 (
                     connection,
                     CommandType.StoredProcedure,
                     "usp_InsertUpdateJobTitle",
                     parameters
                     );
             if (data > 0)
             {
                 return true;
             }
         }
         finally
         {
             SqlHelper.CloseConnection(connection);
         }
     }
     throw new Exception("Unable to update data");
 }
Esempio n. 2
0
        public async Task <IActionResult> UpdateJobTitle([FromBody] JobTitleModel updateJobTitle)
        {
            try
            {
                JobTitle oldJobTitle = await _repository.GetJobTitleByIdAsync(updateJobTitle.Id);

                if (oldJobTitle == null)
                {
                    _logger.LogWarning($"UpdateJobTitle: Job Title was not found with Id: {updateJobTitle.Id}.");
                    return(NotFound($"Job Title was not found with Id: {updateJobTitle.Id}."));
                }

                Department department = await _repository.GetDepartmentByNameAsync(updateJobTitle.InDepartment);

                if (department == null)
                {
                    return(BadRequest($"The department: '{updateJobTitle.InDepartment}' doesn't exist."));
                }
                oldJobTitle.Department = department;

                _mapper.Map(updateJobTitle, oldJobTitle);

                if (await _repository.SaveChangesAsync())
                {
                    _logger.LogInformation($"Successfully updated Job Title with Id: {updateJobTitle.Id}.");
                    return(Ok());
                }
                return(BadRequest("Something went wrong, Job Title has not been updated."));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error during updating Job Title with Id: {updateJobTitle.Id}: {ex}");
                return(StatusCode(StatusCodes.Status500InternalServerError, $"Error during updating Job Title: {ex}"));
            }
        }
        public int UpdateJobTitle(JobTitleModel model)
        {
            using (var trans = db.Database.BeginTransaction())
            {
                try
                {
                    var data = db.JobTitle.FirstOrDefault(u => u.JobTitleId.Equals(model.JobTitleId));
                    if (data != null)
                    {
                        data.Name        = model.Name;
                        data.Description = model.Description;

                        trans.Commit();
                        db.SaveChanges();
                        return(Constants.OK);
                    }
                    else
                    {
                        return(Constants.NOT_FOUND);
                    }
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new ErrorException(ErrorMessage.ERR001, ex.InnerException);
                }
            }
        }
        public void AddJobTitle(JobTitleModel model)
        {
            using (var trans = db.Database.BeginTransaction())
            {
                try
                {
                    JobTitle add = new JobTitle()
                    {
                        JobTitleId  = Guid.NewGuid().ToString(),
                        Name        = model.Name,
                        Description = model.Description,
                        CreateDate  = DateTime.Now,
                        CreateBy    = model.CreateBy,
                    };
                    db.JobTitle.Add(add);

                    db.SaveChanges();
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw new ErrorException(ErrorMessage.ERR001, ex.InnerException);
                }
            }
        }
        public ActionResult Index(string technologies)
        {
            ApiAccess apiAccess = new ApiAccess();
            var       model     = new JobTitleModel();

            model.JobTitles  = new List <string>();
            model.Technology = technologies;
            model.JobTitles  = apiAccess.GetAllJobTitle(technologies);

            return(View("JobTitleIndex", model));
        }
Esempio n. 6
0
        public HttpResponseMessage AddJobTitle(JobTitleModel model)
        {
            try
            {
                jobTitleBusiness.AddJobTitle(model);

                return(Request.CreateResponse(HttpStatusCode.OK, Constants.OK));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Esempio n. 7
0
        //TO DO:Change or Remove
        public static JobTitle MapJobTitleModelToJobTitle(this JobTitleModel jobTitleModel)
        {
            if (jobTitleModel == null)
            {
                return(null);
            }

            var jobTitle = new JobTitle
            {
                JobTitleId = jobTitleModel.Id,
                Name       = jobTitleModel.Name
            };

            return(jobTitle);
        }
Esempio n. 8
0
        public static JobTitleModel MapJobTitleToJobTitleModel(this JobTitle jobTitle)
        {
            if (jobTitle == null)
            {
                return(null);
            }

            var jobTitleModel = new JobTitleModel
            {
                Id   = jobTitle.JobTitleId,
                Name = jobTitle.Name
            };

            return(jobTitleModel);
        }
Esempio n. 9
0
        public bool InsertUpdateJobTile(JobTitleViewModel jobTitleViewModel)
        {
            JobTitleModel jobTitle = new JobTitleModel
            {
                JobTitleId   = jobTitleViewModel.JobTitleId,
                JobTitleName = jobTitleViewModel.JobTitleName,
                UpdatedBy    = jobTitleViewModel.UpdatedBy
            };
            var result = jobTitleRepositroy.InsertUpdateJobTile(jobTitle);

            if (result)
            {
                return(true);
            }
            throw new Exception("Unable to update data");
        }
Esempio n. 10
0
 public HttpResponseMessage UpdateJobTitle(JobTitleModel model)
 {
     try
     {
         int result = jobTitleBusiness.UpdateJobTitle(model);
         if (result == Constants.OK)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, Constants.OK));
         }
         else if (result == Constants.NOT_FOUND)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, Constants.NOT_FOUND));
         }
         return(Request.CreateResponse(HttpStatusCode.OK, Constants.OK));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
Esempio n. 11
0
        public async Task <IActionResult> CreateJobTitle([FromBody] JobTitleModel newJobTitle)
        {
            try
            {
                newJobTitle.Id = 0;

                var jobTitleexists = await _repository.GetJobTitleByNameAsync(newJobTitle.JobTitleName);

                if (jobTitleexists != null)
                {
                    _logger.LogWarning($"Job Title exists: {newJobTitle.JobTitleName} during Create Job Title.");
                    return(BadRequest($"Job Title with the name: '{newJobTitle.JobTitleName}' already exists."));
                }

                var inDepartment = await _repository.GetDepartmentByNameAsync(newJobTitle.InDepartment);

                if (inDepartment == null)
                {
                    _logger.LogWarning($"Department: {newJobTitle.InDepartment} not found during Create Job Title.");
                    return(NotFound($"The department: '{newJobTitle.InDepartment}' doesn't exist."));
                }

                var addJobTitle = _mapper.Map <JobTitle>(newJobTitle);
                addJobTitle.Department = inDepartment;
                _repository.Add(addJobTitle);
                inDepartment.JobTitles.Add(addJobTitle);

                if (await _repository.SaveChangesAsync())
                {
                    _logger.LogInformation($"Successfully created new Job Title: {newJobTitle.JobTitleName}");
                    return(Ok());
                }

                return(BadRequest("Something went wrong, Job Title was not created."));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error during creating new Job Title by Name: {newJobTitle.JobTitleName}: {ex}");
                return(StatusCode(StatusCodes.Status500InternalServerError, $"Error during creating Job title: {ex}"));
            }
        }
Esempio n. 12
0
        public ActionResult GetJobTitleCountById(long JobId)
        {
            var lst = new JobTitleModel();

            try
            {
                if (JobId > 0)
                {
                    lst = _IePeopleManager.GetJobTitleCount(JobId);
                    return(PartialView("~/Views/NewAdmin/ePeople/Requisition/_AddRemoveJobTitleCount.cshtml", lst));
                }
                else
                {
                    return(PartialView("~/Views/NewAdmin/ePeople/Requisition/_AddRemoveJobTitleCount.cshtml", new List <AddChartModel>()));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
            }
            return(PartialView("~/Views/NewAdmin/ePeople/Requisition/_AddRemoveJobTitleCount.cshtml", lst));
        }
Esempio n. 13
0
        /// <summary>
        /// Created By  :Ashwajit bansod
        /// Created Date : 22-Oct-2019
        /// Created For : To send job title for approval
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool SendJobTitleForApproval(JobTitleModel model)
        {
            bool isSaved = false;
            var  Obj     = new AddChartModel();

            try
            {
                var ePeopleRepository = new ePeopleRepository();
                if (model != null)
                {
                    Obj.JobTitleCount = model.JobTitleCount;
                    Obj.Id            = model.JobTitleId;
                    if (model.JobTitleCount > model.JobTitleLastCount)
                    {
                        Obj.ActionStatus    = "Y";
                        Obj.IsActive        = "Y";
                        Obj.RequisitionType = "Add Head Count";
                    }
                    else
                    {
                        Obj.ActionStatus    = "Y";
                        Obj.IsActive        = "Y";
                        Obj.RequisitionType = "Remove Head Count";
                    }
                    isSaved = ePeopleRepository.SendForApproval(Obj);
                    isSaved = true;
                }
                else
                {
                    isSaved = false;
                }
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, " public bool SendJobTitleForApproval(JobTitleModel model)", "Exception While getting send job title for approval.", model);
                throw;
            }
            return(isSaved);
        }
Esempio n. 14
0
        /// <summary>
        /// Created By  :Ashwajit Bansod
        /// Created Date : 22-oct-2019
        /// Created For : To get job details by job Id
        /// </summary>
        /// <param name="JobId"></param>
        /// <returns></returns>
        public JobTitleModel GetJobTitleCount(long JobId)
        {
            var details = new JobTitleModel();

            try
            {
                var ePeopleRepository = new ePeopleRepository();
                var data = ePeopleRepository.GetJobCount(JobId);
                if (data != null)
                {
                    details.JobTitleCount     = data.JBT_JobCount;
                    details.JobTitleId        = data.JBT_Id;
                    details.JobTitle          = data.JBT_JobTitle;
                    details.JobTitleLastCount = data.JBT_JobCount;
                }
                return(details);
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public JobTitleModel GetJobTitleCount(long JobId)", "Exception While getting details of job tilte.", JobId);
                throw;
            }
        }
Esempio n. 15
0
        public JsonResult SendJobCountForApproval(int JobTitleLastCount, int JobTitleId, int JobTitleCount)
        {
            bool IsSaved = false;
            var  model   = new JobTitleModel();

            try
            {
                if (JobTitleLastCount > 0 && JobTitleId > 0 && JobTitleCount > 0)
                {
                    model.JobTitleLastCount = JobTitleLastCount;
                    model.JobTitleId        = JobTitleId;
                    model.JobTitleCount     = JobTitleCount;
                    IsSaved = _IePeopleManager.SendJobTitleForApproval(model);
                    if (IsSaved == true)
                    {
                        ViewBag.Message = CommonMessage.JobCountSendApproval();
                        return(Json(new { Message = ViewBag.Message, AlertMessageClass = ViewBag.AlertMessageClass }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        ViewBag.Message = CommonMessage.FailureMessage();
                        return(Json(new { Message = ViewBag.Message, AlertMessageClass = ViewBag.AlertMessageClass }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    ViewBag.Message = CommonMessage.FailureMessage();
                    return(Json(new { Message = ViewBag.Message, AlertMessageClass = ViewBag.AlertMessageClass }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
            }
            return(Json(new { Message = ViewBag.Message, AlertMessageClass = ViewBag.AlertMessageClass }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 16
0
 public static async Task <ObservableCollection <EmployeeModel> > EmployeeQueryAsync()
 {
     using (var connection = new System.Data.SqlClient.SqlConnection(CnnString(database)))
     {
         var employees = new Dictionary <int, EmployeeModel>();
         await connection.QueryAsync <EmployeeModel>("dbo.spGetEmployeeData_All", new[]
         {
             typeof(EmployeeModel),
             typeof(EmailModel),
             typeof(JobTitleModel),
             typeof(PhoneModel),
             typeof(DepartmentModel),
             typeof(EmployeeStatusModel),
             typeof(CitationModel),
             typeof(CertificationModel),
             typeof(EquipmentAssignmentRecordModel),
             typeof(RestrictionModel)
         }
                                                     , obj =>
         {
             EmployeeModel employeeModel           = obj[0] as EmployeeModel;
             EmailModel emailModel                 = obj[1] as EmailModel;
             JobTitleModel titleModel              = obj[2] as JobTitleModel;
             PhoneModel phoneModel                 = obj[3] as PhoneModel;
             DepartmentModel departmentModel       = obj[4] as DepartmentModel;
             EmployeeStatusModel statusModel       = obj[5] as EmployeeStatusModel;
             CitationModel citationModel           = obj[6] as CitationModel;
             CertificationModel certificationModel = obj[7] as CertificationModel;
             EquipmentAssignmentRecordModel equipmentAssignmentRecord = obj[8] as EquipmentAssignmentRecordModel;
             RestrictionModel restrictionModel = obj[9] as RestrictionModel;
             //employeemodel
             var employeeEntity = new EmployeeModel();
             if (!employees.TryGetValue(employeeModel.Id, out employeeEntity))
             {
                 employees.Add(employeeModel.Id, employeeEntity = employeeModel);
             }
             //list<emailmodel>
             if (employeeEntity.Emails == null)
             {
                 employeeEntity.Emails = new ObservableCollection <EmailModel>();
             }
             if (emailModel != null)
             {
                 if (!employeeEntity.Emails.Any(x => x.Id == emailModel.Id))
                 {
                     employeeEntity.Emails.Add(emailModel);
                 }
             }
             //phonemodel
             if (employeeEntity.Phones == null)
             {
                 employeeEntity.Phones = new ObservableCollection <PhoneModel>();
             }
             if (phoneModel != null)
             {
                 if (!employeeEntity.Phones.Any(x => x.Id == phoneModel.Id))
                 {
                     employeeEntity.Phones.Add(phoneModel);
                 }
             }
             //title
             if (employeeEntity.JobTitle == null)
             {
                 if (titleModel != null)
                 {
                     employeeEntity.JobTitle = titleModel;
                 }
             }
             //department
             if (employeeEntity.Department == null)
             {
                 if (departmentModel != null)
                 {
                     employeeEntity.Department = departmentModel;
                 }
             }
             //status
             if (employeeEntity.Status == null)
             {
                 if (statusModel != null)
                 {
                     employeeEntity.Status = statusModel;
                 }
             }
             //citation
             if (employeeEntity.Citations == null)
             {
                 employeeEntity.Citations = new ObservableCollection <CitationModel>();
             }
             if (citationModel != null)
             {
                 if (!employeeEntity.Citations.Any(x => x.Id == citationModel.Id))
                 {
                     employeeEntity.Citations.Add(citationModel);
                 }
             }
             //certification
             if (employeeEntity.Certifications == null)
             {
                 employeeEntity.Certifications = new ObservableCollection <CertificationModel>();
             }
             if (certificationModel != null)
             {
                 if (!employeeEntity.Certifications.Any(x => x.Id == certificationModel.Id))
                 {
                     employeeEntity.Certifications.Add(certificationModel);
                 }
             }
             //restriction
             if (employeeEntity.Restrictions == null)
             {
                 employeeEntity.Restrictions = new ObservableCollection <RestrictionModel>();
             }
             if (restrictionModel != null)
             {
                 if (!employeeEntity.Restrictions.Any(x => x.Id == restrictionModel.Id))
                 {
                     employeeEntity.Restrictions.Add(restrictionModel);
                 }
             }
             //equipment record
             if (employeeEntity.EquipmentAssignments == null)
             {
                 employeeEntity.EquipmentAssignments = new ObservableCollection <EquipmentAssignmentRecordModel>();
             }
             if (equipmentAssignmentRecord != null)
             {
                 if (!employeeEntity.EquipmentAssignments.Any(x => x.Id == equipmentAssignmentRecord.Id))
                 {
                     employeeEntity.EquipmentAssignments.Add(equipmentAssignmentRecord);
                 }
             }
             return(employeeEntity);
         });;
         var result             = employees.Values.ToList();
         var employeeCollection = new ObservableCollection <EmployeeModel>(result);
         return(employeeCollection);
     }
 }