Example #1
0
        /// <summary>
        /// Calaculates Salary for Contract employee
        /// </summary>
        /// <param name="employee">Employee Model</param>
        /// <returns>Updated employee model</returns>
        public override EmployeeBase CalculateSalary(EmployeeBase employee)
        {
            decimal perDayRate = 500; // rate per day

            employee.Salary = perDayRate * employee.NoOfDays;
            return(employee);
        }
Example #2
0
        public async Task <IActionResult> PutEmployeeBase([FromRoute] int id, [FromBody] EmployeeBase employeeBase)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employeeBase.EmployeeBaseId)
            {
                return(BadRequest());
            }

            _context.Entry(employeeBase).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeBaseExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #3
0
 private void CommonControl_BindingComplete(object sender, BindingCompleteEventArgs e)
 {
     if (e.BindingCompleteState == BindingCompleteState.Exception)
     {
         ExceptionHandlers.ShowExceptionMessageBox(this, e.ErrorText); e.Cancel = true;
     }
     if (sender.Equals(this.bindingSalespersonID) && this.combexSalespersonID.SelectedItem != null)
     {
         EmployeeBase customerBase = (EmployeeBase)this.combexSalespersonID.SelectedItem;
         this.salesOrderViewModel.TeamID = customerBase.TeamID;
     }
     if (sender.Equals(this.bindingCustomerID) && this.combexCustomerID.SelectedItem != null)
     {
         CustomerBase customerBase = (CustomerBase)this.combexCustomerID.SelectedItem;
         this.salesOrderViewModel.CustomerName  = customerBase.Name;
         this.salesOrderViewModel.ContactInfo   = customerBase.ContactInfo;
         this.salesOrderViewModel.SalespersonID = customerBase.SalespersonID;
         //this.salesOrderViewModel.ReceiverID = customerBase.CustomerID;
     }
     if (sender.Equals(this.bindingReceiverID) && this.combexReceiverID.SelectedItem != null)
     {
         CustomerBase customerBase = (CustomerBase)this.combexReceiverID.SelectedItem;
         this.salesOrderViewModel.ReceiverName    = customerBase.Name;
         this.salesOrderViewModel.ShippingAddress = customerBase.ShippingAddress;
     }
 }
 protected override void CommonControl_BindingComplete(object sender, BindingCompleteEventArgs e)
 {
     base.CommonControl_BindingComplete(sender, e);
     if (this.EditableMode)
     {
         if (sender.Equals(this.bindingSalespersonID) && this.combexSalespersonID.SelectedItem != null)
         {
             EmployeeBase customerBase = (EmployeeBase)this.combexSalespersonID.SelectedItem;
             this.deliveryAdviceViewModel.TeamID = customerBase.TeamID;
         }
         if (sender.Equals(this.bindingCustomerID) && this.combexCustomerID.SelectedItem != null)
         {
             CustomerBase customerBase = (CustomerBase)this.combexCustomerID.SelectedItem;
             this.deliveryAdviceViewModel.CustomerName = customerBase.Name; //HERE: CHANGE => DONT SET setDirty: SEE ApplyPropertyChange FOR MORE INFO
             //THIS CommonControl_BindingComplete WILL BE RAISED FOR EVERY BINDING => SO WE CAN NOT UPDATE RELATIVE PROPERTY BY THIS WAY. SHOULD THINK OF NEW WAY FOR UPDATE SUCH RELATIVE PROPERTY (SUCH AS: ContactInfo, ShippingAddress OF Customer)
             //this.deliveryAdviceViewModel.ContactInfo = customerBase.ContactInfo;
             //this.deliveryAdviceViewModel.ShippingAddress = customerBase.ShippingAddress;
         }
         if (sender.Equals(this.bindingReceiverID) && this.combexReceiverID.SelectedItem != null)
         {
             CustomerBase receiverBase = (CustomerBase)this.combexReceiverID.SelectedItem;
             this.deliveryAdviceViewModel.ReceiverName = receiverBase.Name;
             //THIS CommonControl_BindingComplete WILL BE RAISED FOR EVERY BINDING => SO WE CAN NOT UPDATE RELATIVE PROPERTY BY THIS WAY. SHOULD THINK OF NEW WAY FOR UPDATE SUCH RELATIVE PROPERTY (SUCH AS: ContactInfo, ShippingAddress OF Receiver)
             //this.deliveryAdviceViewModel.ContactInfo = receiverBase.ContactInfo;
             //this.deliveryAdviceViewModel.ShippingAddress = receiverBase.ShippingAddress;
         }
     }
 }
 /// <summary>
 /// Add common parameters before calling a procedure
 /// </summary>
 /// <param name="cmd">command object, where parameters will be added</param>
 /// <param name="employeeObject"></param>
 private void AddCommonParams(SqlCommand cmd, EmployeeBase employeeObject)
 {
     AddParameter(cmd, pGuid(EmployeeBase.Property_EmployeeId, employeeObject.EmployeeId));
     AddParameter(cmd, pGuid(EmployeeBase.Property_UserId, employeeObject.UserId));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_Title, 50, employeeObject.Title));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_FirstName, 250, employeeObject.FirstName));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_LastName, 250, employeeObject.LastName));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_Email, 50, employeeObject.Email));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_Street, 500, employeeObject.Street));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_City, 50, employeeObject.City));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_State, 50, employeeObject.State));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_ZipCode, 50, employeeObject.ZipCode));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_Country, 50, employeeObject.Country));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_Phone, 50, employeeObject.Phone));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_SSN, 50, employeeObject.SSN));
     AddParameter(cmd, pBool(EmployeeBase.Property_IsActive, employeeObject.IsActive));
     AddParameter(cmd, pBool(EmployeeBase.Property_IsDeleted, employeeObject.IsDeleted));
     AddParameter(cmd, pBool(EmployeeBase.Property_IsInstaller, employeeObject.IsInstaller));
     AddParameter(cmd, pBool(EmployeeBase.Property_IsSalesPerson, employeeObject.IsSalesPerson));
     AddParameter(cmd, pBool(EmployeeBase.Property_IsServiceCall, employeeObject.IsServiceCall));
     AddParameter(cmd, pDateTime(EmployeeBase.Property_HireDate, employeeObject.HireDate));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_ProfilePicture, 250, employeeObject.ProfilePicture));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_Session, 50, employeeObject.Session));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_JobTitle, 100, employeeObject.JobTitle));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_PlaceOfBirth, 100, employeeObject.PlaceOfBirth));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_SalesCommissionStructure, 100, employeeObject.SalesCommissionStructure));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_TechCommissionStructure, 100, employeeObject.TechCommissionStructure));
     AddParameter(cmd, pBool(EmployeeBase.Property_RecruitmentProcess, employeeObject.RecruitmentProcess));
     AddParameter(cmd, pBool(EmployeeBase.Property_Recruited, employeeObject.Recruited));
     AddParameter(cmd, pDateTime(EmployeeBase.Property_CreatedDate, employeeObject.CreatedDate));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_Status, 50, employeeObject.Status));
     AddParameter(cmd, pNVarChar(EmployeeBase.Property_LastUpdatedBy, 250, employeeObject.LastUpdatedBy));
     AddParameter(cmd, pDateTime(EmployeeBase.Property_LastUpdatedDate, employeeObject.LastUpdatedDate));
 }
            public void CalculatePay()
            {
                EmployeeRecord record = new EmployeeRecord()
                {
                    Type = EmployeeRecord.EmployeeType.HOURLY
                };

                EmployeeBase employee = employeeFactory.CreateEmployee(record);

                employee.CalculatePay();
            }
Example #7
0
        public async Task <IActionResult> PostEmployeeBase([FromBody] EmployeeBase employeeBase)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.EmployeeBase.Add(employeeBase);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEmployeeBase", new { id = employeeBase.EmployeeBaseId }, employeeBase));
        }
Example #8
0
 /// <summary>
 /// Метод, для передачи объекта созданого в контролере
 /// </summary>
 private void ChangeSalary(EmployeeBase employee)
 {
     try
     {
         EmployeeBase = employee;
     }
     catch (ArgumentException exception)
     {
         EmployeeBase = null;
         MessageBox.Show(exception.Message, "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #9
0
        private static void FactoryPatternEmployee()
        {
            EmployeeFactory  employeeFactory = new EmployeeFactory();
            FactoryIEmployee employee        = employeeFactory.GetEmployeeInstance(EmployeeType.PartTime);

            EmployeeBase emp = (EmployeeBase)employee;

            emp.FirstName = "Chandra";
            emp.LastName  = "Sekaran";

            Console.WriteLine("Bonus : {0}", employee.GetBonus());
            Console.WriteLine("Salary : {0}", employee.GetSalary());
            Console.WriteLine("Full Name : {0}", emp.GetFullName());
        }
Example #10
0
        /// <summary>
        /// Calculates the salary for regular employee
        /// </summary>
        /// <param name="employee">Employee Model</param>
        /// <returns>returns the updated employee model</returns>
        public override EmployeeBase CalculateSalary(EmployeeBase employee)
        {
            decimal basicMonthlySalary = 20000;
            decimal Tax    = 0.12m; // Tax 12 %
            decimal salary = basicMonthlySalary - (basicMonthlySalary / 22) - (basicMonthlySalary * Tax);

            if (employee.NoOfDays > 0)
            {
                decimal deducation = (salary / 22) * employee.NoOfDays;
                deducation -= (deducation * Tax);
                salary     -= deducation;
            }
            employee.Salary = salary;
            return(employee);
        }
Example #11
0
        /// <summary>
        /// Method to handle the logic for pair workers, their projects and calculate the total days
        /// </summary>
        /// <param name="employeeList"></param>
        /// <param name="distinctPairs"></param>
        /// <param name="employees"></param>
        /// <param name="projectList"></param>
        /// <returns></returns>
        private static EmployeesProjectCounter MapPairsProjectsAndTotalDays(List <EmployeeBase> employeeList, List <KeyValuePair <int, int> > distinctPairs, List <EmployeesProjectCounter> employees, List <ProjectInfo> projectList)
        {
            foreach (var pair in distinctPairs)
            {
                foreach (var item in projectList)
                {
                    if (item.Employees.Any(x => x.Id == pair.Key) && item.Employees.Any(x => x.Id == pair.Value))
                    {
                        EmployeeBase empl1 = employeeList.Where(x => x.Id == pair.Key && x.ProjectId == item.ProjectId).FirstOrDefault();
                        EmployeeBase empl2 = employeeList.Where(x => x.Id == pair.Value && x.ProjectId == item.ProjectId).FirstOrDefault();
                        // check if dates overlap to see if they actually met each other on the project
                        if (Utils.CheckIfDatesOverlap(empl1.DateFrom, empl1.DateTo, empl2.DateFrom, empl2.DateTo))
                        {
                            int totalDays = Utils.CalculateDaysTogether(empl1.DateFrom, empl1.DateTo, empl2.DateFrom, empl2.DateTo);
                            // we make a check if the object exists, we add project to the counter, else we create a new object
                            if (employees.Where(y => y.EmployeeId == pair.Key && y.Employee2Id == pair.Value).Count() >= 1)
                            {
                                EmployeesProjectCounter employee = employees.Where(x => x.EmployeeId.Equals(pair.Key) && x.Employee2Id.Equals(pair.Value)).FirstOrDefault();
                                employee.ProjectsTogether += 1; // could be removed
                                employee.ProjectDays.Add(new ProjectDays {
                                    ProjectId = item.ProjectId, TotalDays = totalDays
                                });
                            }
                            else
                            {
                                employees.Add(new EmployeesProjectCounter
                                {
                                    EmployeeId       = pair.Key,
                                    Employee2Id      = pair.Value,
                                    ProjectsTogether = 1, // could be removed
                                    ProjectDays      = new List <ProjectDays> {
                                        new ProjectDays {
                                            ProjectId = item.ProjectId, TotalDays = totalDays
                                        }
                                    }
                                });
                            }
                        }
                    }
                }
            }

            List <EmployeesProjectCounter> orderLongestTime = employees.OrderByDescending(x => x.ProjectDays.Max(y => y.TotalDays)).ToList();
            EmployeesProjectCounter        longestTimeOnProjectByColleagues = orderLongestTime[0];

            return(longestTimeOnProjectByColleagues);
        }
Example #12
0
        public User GetUser()
        {
            EmployeeBase employee = null;
            Role         role     = (Role)Role.SelectedItem;

            if (role == Szpital.Role.Administrator)
            {
                employee = new Administrator(new PersonalData(Firstname.Text, Lastname.Text, Address.Text));
            }
            else if (role == Szpital.Role.Pielegniarka)
            {
                employee = new Nurse(new PersonalData(Firstname.Text, Lastname.Text, Address.Text));
            }
            else if (role == Szpital.Role.Lekarz)
            {
                employee = new Doctor(new PersonalData(Firstname.Text, Lastname.Text, Address.Text), PWZ.Text,
                                      (Szpital.Speciality)Speciality.SelectedItem);
            }

            return(new User(Username.Text, Password.Password, employee));
        }
        /// <summary>
        /// Updates Employee
        /// </summary>
        /// <param name="employeeObject">Object to be updated</param>
        /// <returns>Number of rows affected</returns>
        public long Update(EmployeeBase employeeObject)
        {
            try
            {
                SqlCommand cmd = GetSPCommand(UPDATEEMPLOYEE);

                AddParameter(cmd, pInt32(EmployeeBase.Property_Id, employeeObject.Id));
                AddCommonParams(cmd, employeeObject);

                long result = UpdateRecord(cmd);
                if (result > 0)
                {
                    employeeObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow;
                }
                return(result);
            }
            catch (SqlException x)
            {
                throw new ObjectUpdateException(employeeObject, x);
            }
        }
        public void GetSalary(TypeSalary key,
                              params uint[] value)
        {
            switch (key)
            {
            case TypeSalary.Hourly:
            {
                EmployeeBase   salary = SalaryFactory.GetSalary(TypeSalary.Hourly, 140, 400);
                EmployeeHourly result = salary as EmployeeHourly;
                Assert.AreSame(salary, result);
                break;
            }

            case TypeSalary.Rate:
            {
                EmployeeBase salary = SalaryFactory.GetSalary(TypeSalary.Rate, 180, 100000, 180);
                EmployeeRate result = salary as EmployeeRate;
                Assert.AreSame(salary, result);
                break;
            }
            }
        }
        /// <summary>
        /// Inserts Employee
        /// </summary>
        /// <param name="employeeObject">Object to be inserted</param>
        /// <returns>Number of rows affected</returns>
        public long Insert(EmployeeBase employeeObject)
        {
            try
            {
                SqlCommand cmd = GetSPCommand(INSERTEMPLOYEE);

                AddParameter(cmd, pInt32Out(EmployeeBase.Property_Id));
                AddCommonParams(cmd, employeeObject);

                long result = InsertRecord(cmd);
                if (result > 0)
                {
                    employeeObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow;
                    employeeObject.Id       = (Int32)GetOutParameter(cmd, EmployeeBase.Property_Id);
                }
                return(result);
            }
            catch (SqlException x)
            {
                throw new ObjectInsertException(employeeObject, x);
            }
        }
 SomeClass()
 {
     Employee = new Employee();     // OOP in play :)
     Employee = new EmployeeBase(); // Error CS0144
     // Cannot create an instance of the abstract class or interface 'EmployeeBase'
 }
Example #17
0
 /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the  service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, EmployeeBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_GetEmpInfo, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::GrpcEmployee.EmpRequest, global::GrpcEmployee.EmpModel>(serviceImpl.GetEmpInfo));
     serviceBinder.AddMethod(__Method_QueryEmployees, serviceImpl == null ? null : new grpc::UnaryServerMethod <global::GrpcEmployee.SearchRequest, global::GrpcEmployee.EmpModel>(serviceImpl.QueryEmployees));
 }
Example #18
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(EmployeeBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_GetEmpInfo, serviceImpl.GetEmpInfo)
            .AddMethod(__Method_QueryEmployees, serviceImpl.QueryEmployees).Build());
 }
 /// <summary>
 /// Fills Employee object
 /// </summary>
 /// <param name="employeeObject">The object to be filled</param>
 /// <param name="reader">The reader to use to fill a single object</param>
 protected void FillObject(EmployeeBase employeeObject, SqlDataReader reader)
 {
     FillObject(employeeObject, reader, 0);
 }
        /// <summary>
        /// Fills Employee object
        /// </summary>
        /// <param name="employeeObject">The object to be filled</param>
        /// <param name="reader">The reader to use to fill a single object</param>
        /// <param name="start">The ordinal position from which to start reading the reader</param>
        protected void FillObject(EmployeeBase employeeObject, SqlDataReader reader, int start)
        {
            employeeObject.Id         = reader.GetInt32(start + 0);
            employeeObject.EmployeeId = reader.GetGuid(start + 1);
            employeeObject.UserId     = reader.GetGuid(start + 2);
            if (!reader.IsDBNull(3))
            {
                employeeObject.Title = reader.GetString(start + 3);
            }
            if (!reader.IsDBNull(4))
            {
                employeeObject.FirstName = reader.GetString(start + 4);
            }
            if (!reader.IsDBNull(5))
            {
                employeeObject.LastName = reader.GetString(start + 5);
            }
            if (!reader.IsDBNull(6))
            {
                employeeObject.Email = reader.GetString(start + 6);
            }
            if (!reader.IsDBNull(7))
            {
                employeeObject.Street = reader.GetString(start + 7);
            }
            if (!reader.IsDBNull(8))
            {
                employeeObject.City = reader.GetString(start + 8);
            }
            if (!reader.IsDBNull(9))
            {
                employeeObject.State = reader.GetString(start + 9);
            }
            if (!reader.IsDBNull(10))
            {
                employeeObject.ZipCode = reader.GetString(start + 10);
            }
            if (!reader.IsDBNull(11))
            {
                employeeObject.Country = reader.GetString(start + 11);
            }
            if (!reader.IsDBNull(12))
            {
                employeeObject.Phone = reader.GetString(start + 12);
            }
            if (!reader.IsDBNull(13))
            {
                employeeObject.SSN = reader.GetString(start + 13);
            }
            employeeObject.IsActive      = reader.GetBoolean(start + 14);
            employeeObject.IsDeleted     = reader.GetBoolean(start + 15);
            employeeObject.IsInstaller   = reader.GetBoolean(start + 16);
            employeeObject.IsSalesPerson = reader.GetBoolean(start + 17);
            employeeObject.IsServiceCall = reader.GetBoolean(start + 18);
            if (!reader.IsDBNull(19))
            {
                employeeObject.HireDate = reader.GetDateTime(start + 19);
            }
            if (!reader.IsDBNull(20))
            {
                employeeObject.ProfilePicture = reader.GetString(start + 20);
            }
            if (!reader.IsDBNull(21))
            {
                employeeObject.Session = reader.GetString(start + 21);
            }
            if (!reader.IsDBNull(22))
            {
                employeeObject.JobTitle = reader.GetString(start + 22);
            }
            if (!reader.IsDBNull(23))
            {
                employeeObject.PlaceOfBirth = reader.GetString(start + 23);
            }
            if (!reader.IsDBNull(24))
            {
                employeeObject.SalesCommissionStructure = reader.GetString(start + 24);
            }
            if (!reader.IsDBNull(25))
            {
                employeeObject.TechCommissionStructure = reader.GetString(start + 25);
            }
            if (!reader.IsDBNull(26))
            {
                employeeObject.RecruitmentProcess = reader.GetBoolean(start + 26);
            }
            if (!reader.IsDBNull(27))
            {
                employeeObject.Recruited = reader.GetBoolean(start + 27);
            }
            if (!reader.IsDBNull(28))
            {
                employeeObject.CreatedDate = reader.GetDateTime(start + 28);
            }
            if (!reader.IsDBNull(29))
            {
                employeeObject.Status = reader.GetString(start + 29);
            }
            if (!reader.IsDBNull(30))
            {
                employeeObject.LastUpdatedBy = reader.GetString(start + 30);
            }
            if (!reader.IsDBNull(31))
            {
                employeeObject.LastUpdatedDate = reader.GetDateTime(start + 31);
            }
            FillBaseObject(employeeObject, reader, (start + 32));


            employeeObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow;
        }