public Employee(JobTitle position, string fullName, Employee chief)
 {
     this.position = position;
     this.fullName = fullName;
     this.chief    = chief;
 }
示例#2
0
 public bool Create(JobTitle department)
 {
     return(jobTitleRep.Create(department));
 }
示例#3
0
 public bool Update(JobTitle department, string jobCertTypeIds)
 {
     return(jobTitleRep.Update(department, jobCertTypeIds));
 }
示例#4
0
        /// <summary>
        /// Delete by set DeleteFlag = true
        /// </summary>
        /// <param name="objUI"></param>
        private Message Delete(JobTitle objUI)
        {
            Message msg = null;
            try
            {
                if (objUI != null)
                {
                    JobTitle objDb = GetByID(objUI.JobTitleId);
                    if (objDb != null)
                    {
                        bool isValid = true;
                        List<JobTitleLevel> listJobTitle = dbContext.JobTitleLevels.Where(c => c.JobTitleId == objUI.JobTitleId).ToList<JobTitleLevel>();
                        foreach (JobTitleLevel item in listJobTitle)
                        {
                            if (!IsValidDeleteJobTitle(item.ID))
                            {
                                isValid = false;
                                break;
                            }
                        }
                        if (isValid == true)
                        {
                            // Set delete info
                            objDb.DeleteFlag = true;
                            objDb.UpdateDate = DateTime.Now;
                            objDb.UpdatedBy = objUI.UpdatedBy;
                            msg = new Message(MessageConstants.I0001, MessageType.Info, "Job Title", "deleted");
                        }
                        else
                        {
                            msg = new Message(MessageConstants.E0006, MessageType.Error, "delete", "it");
                        }
                    }
                    else
                    {
                        msg = new Message(MessageConstants.E0006, MessageType.Error, "delete", "it");
                    }
                    // Submit changes to dbContext

                    dbContext.SubmitChanges();
                }
            }
            catch
            {
                msg = new Message(MessageConstants.E0006, MessageType.Error, "delete", "it");
            }
            return msg;
        }
        public ActionResult Delete(CodeTableViewModel.CodeCategory category, int id)
        {
            switch (category)
            {
            case CodeTableViewModel.CodeCategory.Medicine:
                Medicine medicine = DB.Medicines.FirstOrDefault(x => x.MedicineId == id);
                if (medicine != null)
                {
                    medicine.Active = !medicine.Active;
                }
                //DB.Medicines.Remove(medicine);
                break;

            case CodeTableViewModel.CodeCategory.Contractor:
                Contractor contractor = DB.Contractors.FirstOrDefault(x => x.ContractorId == id);
                if (contractor != null)
                {
                    contractor.Active = !contractor.Active;
                }
                //DB.Contractors.Remove(contractor);
                break;

            case CodeTableViewModel.CodeCategory.Disease:
                Disease disease = DB.Diseases.FirstOrDefault(x => x.DiseaseId == id);
                if (disease != null)
                {
                    disease.Active = !disease.Active;
                }
                //DB.Diseases.Remove(disease);
                break;

            case CodeTableViewModel.CodeCategory.Relationship:
                Relationship relationship = DB.Relationships.FirstOrDefault(x => x.RelationshipId == id);
                if (relationship != null)
                {
                    relationship.Active = !relationship.Active;
                }
                //DB.Relationships.Remove(relationship);
                break;

            case CodeTableViewModel.CodeCategory.Service:
                Service service = DB.Services.FirstOrDefault(x => x.ServiceId == id);
                if (service != null)
                {
                    service.Active = !service.Active;
                }
                //DB.Services.Remove(service);
                break;

            case CodeTableViewModel.CodeCategory.Activity:
                Activity activity = DB.Activities.FirstOrDefault(x => x.ActivityId == id);
                if (activity != null)
                {
                    activity.Active = !activity.Active;
                }
                //DB.Activities.Remove(activity);
                break;

            case CodeTableViewModel.CodeCategory.ActivityInput:
                ActivityInput activityInput = DB.ActivityInputs.FirstOrDefault(x => x.ActivityInputId == id);
                if (activityInput != null)
                {
                    activityInput.Active = !activityInput.Active;
                }
                //DB.ActivityInputs.Remove(activityInput);
                break;

            case CodeTableViewModel.CodeCategory.Role:
                Role role = DB.Roles.FirstOrDefault(x => x.RoleId == id);
                if (role != null)
                {
                    role.Active = !role.Active;
                }
                //DB.Roles.Remove(role);
                break;

            case CodeTableViewModel.CodeCategory.JobTitle:
                JobTitle jobTitle = DB.JobTitles.FirstOrDefault(x => x.JobTitleId == id);
                if (jobTitle != null)
                {
                    jobTitle.Active = !jobTitle.Active;
                }
                //DB.JobTitles.Remove(jobTitle);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(category), category, null);
            }
            DB.SaveChanges();
            CodeTableViewModel ctvm = new CodeTableViewModel();

            ctvm.Category = category;
            return(RedirectToAction("Index", ctvm));
        }
示例#6
0
 public bool DeleteJobTitle(JobTitle j)
 {
     db.JobTitle.Remove(j);
     return(db.SaveChanges() > 0);
 }
示例#7
0
 /// <summary>
 /// Insert to database
 /// </summary>
 /// <param name="objUI"></param>
 /// <returns></returns>
 public Message Insert(JobTitle objUI)
 {
     Message msg = null;
     try
     {
         if (objUI != null)
         {
             // Set more info
             dbContext.JobTitles.InsertOnSubmit(objUI);
             dbContext.SubmitChanges();
             msg = new Message(MessageConstants.I0001, MessageType.Info, "Job Title '" + objUI.JobTitleName + "'", "added");
         }
     }
     catch (Exception)
     {
         // Show system error
         msg = new Message(MessageConstants.E0007, MessageType.Error);
     }
     return msg;
 }
 public void Post([FromBody] JobTitle value)
 {
     api.CreateJobTitle(value);
 }
 public void Put(int id, [FromBody] JobTitle value)
 {
     api.EditJobTitle(value);
 }
        public async Task UserLogged_DeleteJobTitle_JobTitleDeletedResponseProcessed(HttpStatusCode expectedCode, JobTitle expectedResult)
        {
            using (var mockProvider = AutoMock.GetLoose())
            {
                ///Arrange
                var client = ConfigureClient(expectedCode, expectedResult, mockProvider);

                //Act
                try
                {
                    await client.DeleteJobTitle(1);
                }
                catch (HttpRequestException e)
                {
                    Assert.Equal(expectedCode.ToString(), e.Message);
                }

                //Assert
                ValidateAuthorization(client, "key");
            }
        }
        public async Task UserLogged_UpdateJobTitle_JobTitleUpdatedResponseProcessed(HttpStatusCode expectedCode, JobTitle expectedResult)
        {
            using (var mockProvider = AutoMock.GetLoose())
            {
                //Arrange
                var client = ConfigureClient(expectedCode, expectedResult, mockProvider);

                //Act
                JobTitle result = null;
                try
                {
                    result = await client.UpdateJobTitle(1, expectedResult);
                }
                catch (HttpRequestException e)
                {
                    Assert.Equal(expectedCode.ToString(), e.Message);
                }

                //Assert
                ValidateAuthorization(client, "key");

                if (expectedResult != null)
                {
                    Assert.Equal(JsonConvert.SerializeObject(expectedResult), JsonConvert.SerializeObject(result));
                }
            }
        }
示例#12
0
        public ActionResult Edit(int id = 0)
        {
            JobTitle model = id == 0 ? new JobTitle() : context.JobTitles.Find(id);

            return(View(model));
        }
示例#13
0
        public List <JobTitle> Get()
        {
            JobTitle jt = new JobTitle();

            return(jt.GetAllJT());
        }
        public ActionResult Save(CodeTableViewModel.CodeCategory category, CodeTableViewModel ctvm)
        {
            if (ctvm == null)
            {
                return(RedirectToAction("Index"));
            }

            switch (category)
            {
            case CodeTableViewModel.CodeCategory.Medicine:
                if (ctvm.Medicine != null)
                {
                    Medicine medicine = DB.Medicines.FirstOrDefault(x => x.MedicineId == ctvm.Medicine.MedicineId);
                    if (medicine == null)
                    {
                        if (DB.Medicines.Count(x => x.Code == ctvm.Medicine.Code) > 0)
                        {
                            return(View("Edit", ctvm));
                        }
                        medicine = new Medicine();
                        DB.Medicines.Add(medicine);
                    }
                    medicine.Active = true;
                    medicine.Title  = ctvm.Medicine.Title;
                    medicine.Code   = ctvm.Medicine.Code;
                    medicine.Cost   = ctvm.Medicine.Cost;
                    DB.SaveChanges();
                }
                break;

            case CodeTableViewModel.CodeCategory.Contractor:
                if (ctvm.Contractor != null)
                {
                    Contractor contractor = DB.Contractors.FirstOrDefault(x => x.ContractorId == ctvm.Contractor.ContractorId);
                    if (contractor == null)
                    {
                        if (DB.Contractors.Count(x => x.Number == ctvm.Contractor.Number) > 0)
                        {
                            ctvm.PostOffices = DB.PostOffices.ToList();
                            return(View("Edit", ctvm));
                        }
                        contractor = new Contractor();
                        DB.Contractors.Add(contractor);
                    }
                    contractor.Active     = true;
                    contractor.Number     = ctvm.Contractor.Number;
                    contractor.Title      = ctvm.Contractor.Title;
                    contractor.Address    = ctvm.Contractor.Address;
                    contractor.PostOffice = DB.PostOffices.FirstOrDefault(x => x.PostOfficeId == ctvm.Contractor.PostOffice.PostOfficeId);
                    DB.SaveChanges();
                }
                break;

            case CodeTableViewModel.CodeCategory.Disease:
                if (ctvm.Disease != null)
                {
                    Disease disease = DB.Diseases.FirstOrDefault(x => x.DiseaseId == ctvm.Disease.DiseaseId);
                    if (disease == null)
                    {
                        if (DB.Diseases.Count(x => x.Code == ctvm.Disease.Code) > 0)
                        {
                            return(View("Edit", ctvm));
                        }
                        disease = new Disease();
                        DB.Diseases.Add(disease);
                    }
                    disease.Active      = true;
                    disease.Code        = ctvm.Disease.Code;
                    disease.Description = ctvm.Disease.Description;
                    DB.SaveChanges();
                }
                break;

            case CodeTableViewModel.CodeCategory.Relationship:
                if (ctvm.Relationship != null)
                {
                    Relationship relationship = DB.Relationships.FirstOrDefault(x => x.RelationshipId == ctvm.Relationship.RelationshipId);
                    if (relationship == null)
                    {
                        relationship = new Relationship();
                        DB.Relationships.Add(relationship);
                    }
                    relationship.Name   = ctvm.Relationship.Name;
                    relationship.Active = true;
                    DB.SaveChanges();
                }
                break;

            case CodeTableViewModel.CodeCategory.Service:
                if (ctvm.Service != null)
                {
                    Service service = DB.Services.FirstOrDefault(x => x.ServiceId == ctvm.Service.ServiceId);
                    if (service == null)
                    {
                        if (DB.Services.Count(x => x.ServiceCode == ctvm.Service.ServiceCode) > 0)
                        {
                            return(View("Edit", ctvm));
                        }
                        service = new Service();
                        DB.Services.Add(service);
                    }
                    service.Active              = true;
                    service.ServiceCode         = ctvm.Service.ServiceCode;
                    service.ServiceTitle        = ctvm.Service.ServiceTitle;
                    service.PreventiveVisit     = ctvm.Service.PreventiveVisit;
                    service.RequiresMedicine    = ctvm.Service.RequiresMedicine;
                    service.RequiresBloodSample = ctvm.Service.RequiresBloodSample;
                    service.RequiresPatients    = ctvm.Service.RequiresPatients;
                    service.Cost = ctvm.Service.Cost;
                    DB.SaveChanges();
                }
                break;

            case CodeTableViewModel.CodeCategory.Activity:
                Activity activity = DB.Activities.FirstOrDefault(x => x.ActivityId == ctvm.Activity.ActivityId);
                if (activity == null)
                {
                    if (DB.Activities.Count(x => x.ActivityCode == ctvm.Activity.ActivityCode) > 0)
                    {
                        return(View("Edit", ctvm));
                    }
                    activity = new Activity();
                    DB.Activities.Add(activity);
                }
                activity.Active        = true;
                activity.ActivityCode  = ctvm.Activity.ActivityCode;
                activity.ActivityTitle = ctvm.Activity.ActivityTitle;
                //activity.ActivityInputFor = ctvm.Activity.ActivityInputFor;
                DB.SaveChanges();
                break;

            case CodeTableViewModel.CodeCategory.ActivityInput:
                ActivityInput activityInput = DB.ActivityInputs.FirstOrDefault(x => x.ActivityInputId == ctvm.ActivityInput.ActivityInputId);
                if (activityInput == null)
                {
                    activityInput = new ActivityInput();
                    DB.ActivityInputs.Add(activityInput);
                }
                activityInput.Active         = true;
                activityInput.Title          = ctvm.ActivityInput.Title;
                activityInput.InputType      = ctvm.ActivityInput.InputType;
                activityInput.PossibleValues = ctvm.ActivityInput.PossibleValues;
                DB.SaveChanges();
                break;

            case CodeTableViewModel.CodeCategory.Role:
                Role role = DB.Roles.FirstOrDefault(x => x.RoleId == ctvm.Role.RoleId);
                if (role == null)
                {
                    role = new Role();
                    DB.Roles.Add(role);
                }
                role.Title = ctvm.Role.Title;
                DB.SaveChanges();
                break;

            case CodeTableViewModel.CodeCategory.JobTitle:
                JobTitle jobTitle = DB.JobTitles.FirstOrDefault(x => x.JobTitleId == ctvm.JobTitle.JobTitleId);
                if (jobTitle == null)
                {
                    jobTitle = new JobTitle();
                    DB.JobTitles.Add(jobTitle);
                }
                jobTitle.Active = true;
                jobTitle.Title  = ctvm.JobTitle.Title;
                DB.SaveChanges();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(category), category, null);
            }
            DB.SaveChanges();
            ctvm          = new CodeTableViewModel();
            ctvm.Category = category;
            return(RedirectToAction("Index", ctvm));
        }
示例#15
0
文件: Service.cs 项目: satijas/WSA
    public HttpResponseMessage<JobTitle> AddJobTitle(JobTitle jobtitle)
    {
        // Add the region that was passed in as the argument
            context.JobTitles.Add(jobtitle);
            context.SaveChanges();

            // Prepare the response - we want to return "201 Created"
            HttpResponseMessage<JobTitle> response = new HttpResponseMessage<JobTitle>(jobtitle, HttpStatusCode.Created);
            return response;
    }
 public void Post([FromBody] JobTitle value)
 {
     _jobsWebRepository.CreateAsync(value).Wait();
 }
示例#17
0
 /// <summary>
 /// Initializes members
 /// </summary>
 /// <param name="firstName">First name of an employee </param>
 /// <param name="lastName">Last name of an employee</param>
 /// <param name="email">Gender of an employee</param>
 /// <param name="bsnNumber">BSN number of an employee</param>
 /// <param name="address">Address of an employee</param>
 /// <param name="phoneNumber">Phone number of an employee</param>
 /// <param name="dateOfBirth">Date of birth of an employee</param>
 /// <param name="gender">Gender of an employee</param>
 /// <param name="jobTitle">Job title of an employee</param>
 public Employee(string firstName, string lastName, string email, int bsnNumber, string address, long phoneNumber, DateTime dateOfBirth, Gender gender, JobTitle jobTitle)
 {
     FirstName   = firstName;
     LastName    = lastName;
     Email       = email;
     BsnNumber   = bsnNumber;
     Address     = address;
     PhoneNumber = phoneNumber;
     DateOfBirth = dateOfBirth;
     Gender      = gender;
     JobTitle    = jobTitle;
 }
 public void Put(int id, [FromBody] JobTitle value)
 {
     _jobsWebRepository.Update(id, value).Wait();
 }
示例#19
0
 public bool InsertJobTitle(JobTitle j)
 {
     db.JobTitle.Add(j);
     return(db.SaveChanges() > 0);
 }
示例#20
0
 public override string ToString()
 {
     return(EmployeeId.ToString().PadRight(5) + (LastName + "," + FirstName).PadRight(30) + JobTitle.PadRight(30) + Gender.PadRight(3) + BirthDate.ToShortDateString().PadRight(10));
 }
示例#21
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="objUI"></param>
        /// <returns></returns>
        public Message Update(JobTitle objUI)
        {
            Message msg = null;
            try
            {
                if (objUI != null)
                {
                    JobTitle objDB = GetByID(objUI.JobTitleId);
                    if (IsValidExamUpdateDate(objUI, objDB, out msg))
                    {
                        objDB.JobTitleName = objUI.JobTitleName;
                        objDB.DepartmentId = objUI.DepartmentId;
                        objDB.Description = objUI.Description;
                        objDB.IsManager = objUI.IsManager;

                        // Set more info
                        objDB.UpdateDate = DateTime.Now;
                        objDB.UpdatedBy = objUI.UpdatedBy;

                        dbContext.SubmitChanges();
                        msg = new Message(MessageConstants.I0001, MessageType.Info, "Job Title '" + objUI.JobTitleName + "'", "updated");
                    }
                }
            }
            catch (Exception)
            {
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            return msg;
        }
示例#22
0
        public async Task UserLogged_GetJobTitle_JobTitleReceived(int titleId, HttpStatusCode expectedStatus, JobTitle clientResult)
        {
            //Arrange
            mockProvider.Mock <IJobTitlesServiceClient>().Setup(c => c.GetJobTitle(titleId)).ReturnsAsync(clientResult);

            var request = new HttpRequestMessage(HttpMethod.Get, $"{Constants.API_BASE_URL}{Constants.CURRENT_VERSION}/{Constants.JOB_TITLE_RESOURCE}{titleId}");

            request.Headers.Add(Constants.AUTHORIZATION, $"{Constants.BASIC} user:pass");

            //Act
            var response = await client.SendAsync(request);

            //Assert
            Assert.Equal(expectedStatus, response.StatusCode);
        }
示例#23
0
        /// <summary>
        /// Check update date whether is valid
        /// </summary>
        /// <param name="objUI"></param>
        /// <param name="objDb"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private bool IsValidExamUpdateDate(JobTitle objUI, JobTitle objDb, out Message msg)
        {
            bool isValid = false;
            msg = null;

            try
            {
                if ((objUI != null) && (objUI.UpdateDate != null))
                {
                    if (objDb != null)
                    {
                        if (objDb.UpdateDate.ToString().Equals(objUI.UpdateDate.ToString()))
                        {
                            isValid = true;
                        }
                        else
                        {
                            msg = new Message(MessageConstants.E0025, MessageType.Error, "Job Title '" + objDb.JobTitleName + "'");
                        }
                    }
                }
            }
            catch
            {
                throw;
            }

            return isValid;
        }
示例#24
0
        public async Task <ActionResult <JobTitle> > PostJobTitle(JobTitle jobTitle)
        {
            _jobTitleRepository.Add(jobTitle);

            return(new OkObjectResult(200));
        }