Exemplo n.º 1
0
        public async Task <IActionResult> PutWage([FromRoute] int id, [FromBody] Wage wage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != wage.ID)
            {
                return(BadRequest());
            }

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

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

            var updatedWage = _context.Wages.Include(w => w.Year).SingleOrDefaultAsync(w => w.ID == wage.ID);

            return(Ok(updatedWage));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,Dollars,Hours, RestaurantId")] Wage wage)
        {
            var routeId = RouteData.Values["restaurantId"].ToString();

            if (id != wage.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(wage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WageExists(wage.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", new { restaurantId = routeId }));
            }

            ViewData["UserId"]       = new SelectList(_context.ApplicationUsers.Where(u => u.Id == wage.UserId), "Id", "FullName");
            ViewData["RestaurantId"] = new SelectList(_context.Restaurants.Where(r => r.Id == Int32.Parse(routeId)), "Id", "Name");
            return(View(wage));
        }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is Shift other &&
                   ((Id == null && other.Id == null) || (Id?.Equals(other.Id) == true)) &&
                   ((EmployeeId == null && other.EmployeeId == null) || (EmployeeId?.Equals(other.EmployeeId) == true)) &&
                   ((LocationId == null && other.LocationId == null) || (LocationId?.Equals(other.LocationId) == true)) &&
                   ((Timezone == null && other.Timezone == null) || (Timezone?.Equals(other.Timezone) == true)) &&
                   ((StartAt == null && other.StartAt == null) || (StartAt?.Equals(other.StartAt) == true)) &&
                   ((EndAt == null && other.EndAt == null) || (EndAt?.Equals(other.EndAt) == true)) &&
                   ((Wage == null && other.Wage == null) || (Wage?.Equals(other.Wage) == true)) &&
                   ((Breaks == null && other.Breaks == null) || (Breaks?.Equals(other.Breaks) == true)) &&
                   ((Status == null && other.Status == null) || (Status?.Equals(other.Status) == true)) &&
                   ((Version == null && other.Version == null) || (Version?.Equals(other.Version) == true)) &&
                   ((CreatedAt == null && other.CreatedAt == null) || (CreatedAt?.Equals(other.CreatedAt) == true)) &&
                   ((UpdatedAt == null && other.UpdatedAt == null) || (UpdatedAt?.Equals(other.UpdatedAt) == true)) &&
                   ((TeamMemberId == null && other.TeamMemberId == null) || (TeamMemberId?.Equals(other.TeamMemberId) == true)));
        }
Exemplo n.º 4
0
        public void ShouldUpdateWage()
        {
            //Arrange.
            const int vacancyReferenceNumber = 1;
            var       closingDate            = DateTime.Today.AddDays(20);
            var       possibleStartDate      = DateTime.Today.AddDays(30);

            var wageViewModel = new WageViewModel()
            {
                Type             = WageType.Custom,
                CustomType       = CustomWageType.Fixed,
                Amount           = 450,
                AmountLowerBound = null,
                AmountUpperBound = null,
                Text             = null,
                Unit             = WageUnit.Monthly,
                HoursPerWeek     = 37.5m
            };
            var wage = new Wage(WageType.Custom, 450, null, null, null, WageUnit.Monthly, 37.5m, null);

            var updatedViewModel = new FurtherVacancyDetailsViewModel
            {
                VacancyDatesViewModel = new VacancyDatesViewModel
                {
                    ClosingDate       = new DateViewModel(closingDate),
                    PossibleStartDate = new DateViewModel(possibleStartDate)
                },
                VacancyReferenceNumber = vacancyReferenceNumber,
                Wage = wageViewModel
            };

            var dbApprenticeshipVacancy = new Vacancy
            {
                VacancyReferenceNumber = vacancyReferenceNumber,
                Wage = new Wage(WageType.NationalMinimum, null, null, null, "Legacy text", WageUnit.Weekly, 30, null)
            };

            MockVacancyPostingService.Setup(s => s.GetVacancyByReferenceNumber(vacancyReferenceNumber))
            .Returns(dbApprenticeshipVacancy);
            MockVacancyPostingService.Setup(s => s.UpdateVacancy(It.IsAny <Vacancy>()))
            .Returns(dbApprenticeshipVacancy);
            MockMapper.Setup(m => m.Map <WageViewModel, Wage>(It.IsAny <WageViewModel>())).Returns(wage);
            MockMapper.Setup(m => m.Map <Wage, WageViewModel>(It.IsAny <Wage>())).Returns(wageViewModel); //this line kind of invalidates this test.
            MockMapper.Setup(m => m.Map <Vacancy, FurtherVacancyDetailsViewModel>(dbApprenticeshipVacancy))
            .Returns(updatedViewModel);

            var provider = GetVacancyPostingProvider();

            //Act.
            provider.UpdateVacancyDates(updatedViewModel);

            //Assert.
            MockVacancyPostingService.Verify(s => s.UpdateVacancy(It.Is <Vacancy>(
                                                                      v => v.PossibleStartDate == possibleStartDate &&
                                                                      v.Wage.Type == updatedViewModel.Wage.Type &&
                                                                      v.Wage.Amount == updatedViewModel.Wage.Amount &&
                                                                      v.Wage.Text == dbApprenticeshipVacancy.Wage.Text &&
                                                                      v.Wage.Unit == updatedViewModel.Wage.Unit &&
                                                                      v.Wage.HoursPerWeek == dbApprenticeshipVacancy.Wage.HoursPerWeek)));
        }
Exemplo n.º 5
0
        public List <Wage> GetWageReportAdvance(DateTime?startDate, DateTime?endDate)
        {
            List <Wage> wages   = new List <Wage>();
            string      cmdText = "select employeeID, [date], wage from wages order by [date] DESC";

            SqlCommand command = new SqlCommand(cmdText, connection);

            SqlDataReader result = command.ExecuteReader();

            if (result.HasRows)
            {
                while (result.Read())
                {
                    float w    = result.GetFloat(2);
                    Wage  wage = new Wage(result.GetInt32(0), null, w);
                    wage.date = result.GetDateTime(1);
                    wages.Add(wage);
                }
            }
            result.Close();

            if (startDate != null)
            {
                wages.RemoveAll(x => x.date < startDate);
            }
            if (endDate != null)
            {
                wages.RemoveAll(x => x.date > endDate);
            }

            return(wages);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 更新指定工资记录对象
 /// </summary>
 /// <param name="wage">工资记录对象</param>
 public void Update(Wage wage)
 {
     using (var context = new SchoolOAContext())
     {
         context.Wage.Update(wage);
         context.SaveChanges();
     }
 }
        public void ShouldGetTheCorrectWageUnitForCustomWages(WageUnit wageUnit, WageUnit expected)
        {
            var wage = new Wage(WageType.Custom, null, null, null, string.Empty, wageUnit, null, null);

            var actual = wage.Unit;

            actual.Should().Be(expected);
        }
        public void ShouldGetTheCorrectWageUnitForNonCustomWages(WageType wageType, WageUnit expected)
        {
            var wage = new Wage(wageType, null, null, null, string.Empty, WageUnit.NotApplicable, null, null);
            // Act.
            var actual = wage.Unit;

            // Assert.
            actual.Should().Be(expected);
        }
Exemplo n.º 9
0
        public void ShouldSetCorrectWageUnit(WageType type, WageUnit suppliedUnit, WageUnit expectedUnit)
        {
            //Arrange
            //Act
            var result = new Wage(type, null, null, null, null, suppliedUnit, null, null);

            //Assert
            result.Unit.Should().Be(expectedUnit);
        }
Exemplo n.º 10
0
        public ResultJSON <Wage> Post([FromBody] Wage wage)
        {
            r.FirstOrDefault(u => u.Name == wage.Name).Security = wage.安全保障金;

            return(new ResultJSON <Wage>
            {
                Code = 0,
                Data = wr.InsertOrUpdate(wage)
            });
        }
Exemplo n.º 11
0
        public async Task <Wage> Create(int employeeId, Wage wage)
        {
            var wageModel = modelMapper.Map(wage);

            wageModel.EmployeeId = employeeId;

            var result = await repository.Add(wageModel);

            return(entityMapper.Map(result));
        }
Exemplo n.º 12
0
        public void ShouldFormatUnspecifiedWageCorrectly()
        {
            var wage = new Wage
            {
                WageType = WageType.Unspecified
            };

            var actual = wage.ToText(null);

            actual.Should().Be("Unspecified");
        }
Exemplo n.º 13
0
        public void ShouldFormatNationalMinimumWageForApprenticesCorrectly()
        {
            var wage = new Wage
            {
                WageType    = WageType.NationalMinimumWageForApprentices,
                WeeklyHours = 37.555m
            };

            var actual = wage.ToText(new DateTime(2018, 5, 1));

            actual.Should().Be("£7,225.58");
        }
Exemplo n.º 14
0
        public void ShouldFormatNationalMinimumWageCorrectly()
        {
            var wage = new Wage
            {
                WageType    = WageType.NationalMinimumWage,
                WeeklyHours = 37.555m
            };

            var actual = wage.ToText(new DateTime(2018, 5, 1));

            actual.Should().Be("£8,202.01 - £15,290.89");
        }
Exemplo n.º 15
0
        public async Task <IActionResult> PostWage([FromBody] Wage wage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Wages.Add(wage);
            await _context.SaveChangesAsync();

            return(Ok(_context.Wages.Include(w => w.Year).FirstOrDefault(e => e.ID == wage.ID)));
        }
Exemplo n.º 16
0
        public Wage CreateWageBand()
        {
            var wg1 = new Wage
            {
                Code       = "EL1",
                Hourly     = true,
                HourlyRate = 2.33f,
            };

            wg1.Operatives.Add(person);
            return(wg1);
        }
Exemplo n.º 17
0
        public void ShouldFormatFixedWageCorrectly()
        {
            var wage = new Wage
            {
                WageType = WageType.FixedWage,
                FixedWageYearlyAmount = 12345678.91m
            };

            var actual = wage.ToText(null);

            actual.Should().Be("£12,345,678.91");
        }
Exemplo n.º 18
0
        public async Task <IActionResult> Create([Bind("Id,UserId,Dollars,Hours")] Wage wage)
        {
            if (ModelState.IsValid)
            {
                var routeId = RouteData.Values["restaurantId"].ToString();
                wage.RestaurantId = Int32.Parse(routeId);
                _context.Add(wage);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", new { restaurantId = routeId }));
            }
            return(View(wage));
        }
Exemplo n.º 19
0
        /// <summary>
        /// 查询教师ID的某月的工资记录
        /// </summary>
        /// <param name="teacherid">教师ID</param>
        /// <param name="time">工资日期(月份输入举例 eg:2019-01-01表示查询2019年1月工资)</param>
        /// <returns>指定工资记录</returns>
        public Wage QuerybyTidMonth(string teacherid, string time)
        {
            Wage     wage = new Wage();
            DateTime dt   = Convert.ToDateTime(time);

            using (var context = new SchoolOAContext())
            {
                wage = (from u in context.Wage
                        where (0 == DateTime.Compare(u.Wagetime, dt)) && (u.Teacherid.Equals(teacherid))
                        select u
                        ).FirstOrDefault();
                context.SaveChanges();
            }
            return(wage);
        }
Exemplo n.º 20
0
        public List <Wage> GetWageReport(DateTime?startDate, DateTime?endDate)
        {
            List <Wage> wages   = new List <Wage>();
            string      cmdText = "dbo.WageReport";

            SqlCommand command = new SqlCommand(cmdText, connection);

            command.CommandType = System.Data.CommandType.StoredProcedure;

            if (startDate == null)
            {
                startDate = FirstMoneyEntry();
            }
            if (endDate == null)
            {
                endDate = DateTime.Now.AddDays(1);
            }
            else
            {
                endDate.Value.AddDays(1);
            }

            command.Parameters.Add(new SqlParameter("@startDate", startDate));
            command.Parameters.Add(new SqlParameter("@endDate", endDate));
            SqlDataReader result = command.ExecuteReader();

            if (result.HasRows)
            {
                while (result.Read())
                {
                    float w;
                    if (result.IsDBNull(2))
                    {
                        w = 0;
                    }
                    else
                    {
                        w = (float)result.GetDouble(2);
                    }
                    Wage wage = new Wage(result.GetInt32(0), result.GetInt32(1), w);
                    wages.Add(wage);
                }
                result.Close();
            }
            result.Close();

            return(wages);
        }
Exemplo n.º 21
0
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"Id = {(Id == null ? "null" : Id == string.Empty ? "" : Id)}");
     toStringOutput.Add($"EmployeeId = {(EmployeeId == null ? "null" : EmployeeId == string.Empty ? "" : EmployeeId)}");
     toStringOutput.Add($"LocationId = {(LocationId == null ? "null" : LocationId == string.Empty ? "" : LocationId)}");
     toStringOutput.Add($"Timezone = {(Timezone == null ? "null" : Timezone == string.Empty ? "" : Timezone)}");
     toStringOutput.Add($"StartAt = {(StartAt == null ? "null" : StartAt == string.Empty ? "" : StartAt)}");
     toStringOutput.Add($"EndAt = {(EndAt == null ? "null" : EndAt == string.Empty ? "" : EndAt)}");
     toStringOutput.Add($"Wage = {(Wage == null ? "null" : Wage.ToString())}");
     toStringOutput.Add($"Breaks = {(Breaks == null ? "null" : $"[{ string.Join(", ", Breaks)} ]")}");
     toStringOutput.Add($"Status = {(Status == null ? "null" : Status.ToString())}");
     toStringOutput.Add($"Version = {(Version == null ? "null" : Version.ToString())}");
     toStringOutput.Add($"CreatedAt = {(CreatedAt == null ? "null" : CreatedAt == string.Empty ? "" : CreatedAt)}");
     toStringOutput.Add($"UpdatedAt = {(UpdatedAt == null ? "null" : UpdatedAt == string.Empty ? "" : UpdatedAt)}");
     toStringOutput.Add($"TeamMemberId = {(TeamMemberId == null ? "null" : TeamMemberId == string.Empty ? "" : TeamMemberId)}");
 }
Exemplo n.º 22
0
 /// <summary>
 /// 用基本工资创建工资记录
 /// </summary>
 /// <param name="teacherid">教师ID</param>
 /// <param name="wagetime">工资日期</param>
 /// <param name="basicwage">基本工资</param>
 public void Add(string teacherid, string wagetime, float basicwage)
 {
     using (SchoolOAContext context = new SchoolOAContext())
     {
         DateTime dt   = Convert.ToDateTime(wagetime);
         Wage     wage = new Wage
         {
             Teacherid = teacherid,
             Wagetime  = dt,
             Basicwage = basicwage,
             Totalwage = basicwage
         };
         context.Wage.Add(wage);
         context.SaveChanges();
     }
 }
Exemplo n.º 23
0
        public static Wage Convert(WageDto wageDto)
        {
            if (wageDto == null)
            {
                return(null);
            }
            Wage country = new Wage();

            country.CurrentSum = wageDto.CurrentSum;
            country.IDWage     = wageDto.IDWage;
            country.Manager    = wageDto.Manager.IDManager;
            country.Paid       = wageDto.Paid;
            country.Rest       = wageDto.Rest;
            country.SumOrders  = wageDto.SumOrders;
            return(country);
        }
Exemplo n.º 24
0
        public static WageDto Convert(Wage country)
        {
            if (country == null)
            {
                return(null);
            }
            WageDto countryDto = new WageDto();

            countryDto.CurrentSum = country.CurrentSum;
            countryDto.IDWage     = country.IDWage;
            countryDto.Manager    = Convert(DaoFactory.GetManagersDao().Get(country.Manager));
            countryDto.Paid       = country.Paid;
            countryDto.Rest       = country.Rest;
            countryDto.SumOrders  = country.SumOrders;
            return(countryDto);
        }
        protected override OpResult _Store(Wage _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "Wage object cannot be created as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_UpdateQuery(_obj));
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj));
            }

            ExecuteNonQuery(GetQuery_InsertQuery(_obj));
            _obj.FromDb = true;
            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
        public async Task And_Has_Duration_Then_In_Progress(
            Wage wage,
            DateTime closingDate,
            DisplayVacancyViewModelMapper mapper)
        {
            var vacancy = CreateCompletedSectionOneVacancy();

            vacancy.Id          = Guid.NewGuid();
            vacancy.Wage        = wage;
            vacancy.ClosingDate = closingDate;
            vacancy.StartDate   = closingDate.AddMonths(1);
            var model = new VacancyPreviewViewModel();
            await mapper.MapFromVacancyAsync(model, vacancy);

            model.SetSectionStates(model, new ModelStateDictionary());

            model.TaskListSectionTwoState.Should().Be(VacancyTaskListSectionState.InProgress);
        }
Exemplo n.º 27
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < gridView.DataRowCount; i++)
            {
                Wage temp = gridView.GetRow(i) as Wage;
                temp.CoefficientsID = temp.WageCoefficientInfo.ID;
                temp.EmployeeID     = temp.EmployeeInfo.UseName;
                temp.AdminID        = temp.AdminInfo.UseName;

                string message = _manager.InsertOrUpdate(temp).GetErrorMessages();
                if (message.Length > 0)
                {
                    MessageBox.Show(message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            btnRefresh_Click(null, null);
            btnSave.Enabled = false;
        }
Exemplo n.º 28
0
        private void repDateEstab_EditValueChanging(object sender, ChangingEventArgs e)
        {
            DateTime date  = (DateTime)e.NewValue;
            string   usEpl = ((Wage)gridView.GetRow(gridView.FocusedRowHandle)).EmployeeID;

            for (int i = 0; i < gridView.RowCount; i++)
            {
                Wage w = (Wage)gridView.GetRow(i);
                if (w != null)
                {
                    if (w.EmployeeID == usEpl && w.DateEstablished.Year == date.Year && w.DateEstablished.Month == date.Month)
                    {
                        e.Cancel = true;
                        MessageBox.Show("This Wage had been exited!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                }
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// 新建工资记录
 /// </summary>
 /// <param name="teacherid">教师ID</param>
 /// <param name="wagetime"> 工资日期,格式:“2019-08-01”代表2019-08的工资</param>
 /// <param name="basicwage">基本工资</param>
 /// <param name="overtimewage">加班工资</param>
 /// <param name="welfare">福利工资</param>
 /// <param name="bonus">全勤奖</param>
 public void Add(string teacherid, string wagetime, float basicwage, float?overtimewage, float?welfare, float?bonus)
 {
     using (SchoolOAContext context = new SchoolOAContext())
     {
         DateTime dt   = Convert.ToDateTime(wagetime);
         Wage     wage = new Wage
         {
             Teacherid    = teacherid,
             Wagetime     = dt,
             Basicwage    = basicwage,
             Overtimewage = overtimewage,
             Welfare      = welfare,
             Bonus        = bonus,
             Totalwage    = basicwage + overtimewage + welfare + bonus
         };
         context.Wage.Add(wage);
         context.SaveChanges();
     }
 }
Exemplo n.º 30
0
        private void repEmployees_EditValueChanging(object sender, ChangingEventArgs e)
        {
            string useName = ((Member)e.NewValue).UseName;

            for (int i = 0; i < gridView.RowCount; i++)
            {
                Wage w = (Wage)gridView.GetRow(i);
                if (w != null)
                {
                    if (w.EmployeeInfo.UseName == useName &&
                        w.DateEstablished.Year == ((DateTime)gridView.GetRowCellValue(gridView.FocusedRowHandle, "DateEstablished")).Year
                        &&
                        w.DateEstablished.Month == ((DateTime)gridView.GetRowCellValue(gridView.FocusedRowHandle, "DateEstablished")).Month)
                    {
                        e.Cancel = true;
                        MessageBox.Show("This Wage had been exited!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                }
            }
        }