コード例 #1
0
        /// <summary>
        /// Checks Name
        /// </summary>
        /// <param name="viewModel">Injected <see cref="AddYear"/></param>
        /// <returns>Instance of <see cref="Task{Year}"/></returns>
        public async Task <Year> CheckNumber(AddYear @viewModel)
        {
            Year @Year = await Context.Year
                         .TagWith("CheckNumber")
                         .AsNoTracking()
                         .FirstOrDefaultAsync(x => x.Number == @viewModel.Number);

            if (@Year != null)
            {
                // Log
                string @logData = @Year.GetType().Name
                                  + " with Number "
                                  + @Year.Number
                                  + " was already found at "
                                  + DateTime.Now.ToShortTimeString();

                Logger.WriteGetItemFoundLog(@logData);

                throw new Exception(@Year.GetType().Name
                                    + " with Number "
                                    + @viewModel.Number
                                    + " already exists");
            }

            return(@Year);
        }
コード例 #2
0
        /// <summary>
        /// Adds Year
        /// </summary>
        /// <param name="viewModel">Injected <see cref="AddYear"/></param>
        /// <returns>Instance of <see cref="Task{ViewYear}"/></returns>
        public async Task <ViewYear> AddYear(AddYear @viewModel)
        {
            await CheckNumber(@viewModel);

            Year @Year = new()
            {
                Number = @viewModel.Number
            };

            try
            {
                await Context.Year.AddAsync(@Year);

                await Context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                await CheckNumber(@viewModel);
            }

            // Log
            string @logData = @Year.GetType().Name
                              + " with Id "
                              + @Year.Id
                              + " was added at "
                              + DateTime.Now.ToShortTimeString();

            Logger.WriteInsertItemLog(@logData);

            return(Mapper.Map <ViewYear>(@Year));
        }
コード例 #3
0
        internal void CertEdit()
        {
            // Populate the excel data
            GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "ProfilePage");

            GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//a[@data-tab='fourth']"));

            //Click Certification tab
            ClickCert.Click();
            EditCert.Click();

            //Edit Certification
            AddCert.Clear();
            AddCert.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Certificate"));

            //Edit Certification from
            AddCertFrom.Clear();
            AddCertFrom.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "From"));

            //Edit Certification year
            AddYear.SendKeys(GlobalDefinitions.ExcelLib.ReadData(3, "Year"));

            //Click update
            UpdateCert.Click();
        }