Пример #1
0
        /// <summary>
        /// Adding the specified employee details
        /// </summary>
        /// <param name="employee">The employee</param>
        /// <returns></returns>
        public Task <int> AddEmployee(GreetingModel employee)
        {
            userDbContext.Employee.Add(employee);
            var result = userDbContext.SaveChangesAsync();

            return(result);
        }
Пример #2
0
        public ViewResult Index(string name)
        {
            var model = new GreetingModel();

            model.Name = name;
            return(View(model));
        }
Пример #3
0
        /// <summary>
        /// Updates the specified employee
        /// </summary>
        /// <param name="employeeChanges">The employeeChanges</param>
        /// <returns>Updated id</returns>
        public Task <int> UpdateEmployee(GreetingModel employeeChanges)
        {
            var employee = userDbContext.Employee.Attach(employeeChanges);

            employee.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            var result = userDbContext.SaveChangesAsync();

            return(result);
        }
Пример #4
0
        public ActionResult Index()
        {
            var model = new GreetingModel
            {
                Greeting = "Welcome to the world of MVC",
                Name     = "Your friendly neighborhood MVC App"
            };

            return(View(model));
        }
Пример #5
0
        public IActionResult Index()
        {
            GreetingModel model = new GreetingModel()
            {
                CreateDate = DateTime.Now,
                Id         = 1,
                Message    = _greeting.GetMessageOfDay()
            };

            return(View(model));
        }
Пример #6
0
        public GreetingModel Delete(int Employeeid)
        {
            GreetingModel model = _context.Employees.Find(Employeeid);

            if (model != null)
            {
                _context.Employees.Remove(model);
            }
            _context.SaveChanges();
            return(model);
        }
Пример #7
0
        /// <summary>
        /// Deletes the specified employee
        /// </summary>
        /// <param name="id">The id</param>
        /// <returns>Deleted Employee</returns>
        public GreetingModel DeleteEmployee(int id)
        {
            GreetingModel employee = userDbContext.Employee.Find(id);

            if (employee != null)
            {
                userDbContext.Employee.Remove(employee);
                userDbContext.SaveChanges();
            }
            return(employee);
        }
Пример #8
0
        public IActionResult LoginEmployee(GreetingModel model)
        {
            var result = this.manager.LoginEmployee(model.Email, model.Password);

            if (result == true)
            {
                return(this.Ok(model.Email));
            }
            else
            {
                return(this.BadRequest());
            }
        }
Пример #9
0
        public async Task <IActionResult> AddEmployee(GreetingModel employee)
        {
            var result = await this._Manager.AddEmployee(employee);

            if (result == 1)
            {
                return(this.Ok(employee));
            }
            else
            {
                Log.Error("This is bad network");
                return(this.BadRequest());
            }
        }
Пример #10
0
        public async Task <IActionResult> UpdateEmployee(GreetingModel employeeChanges)
        {
            var result = await this.manager.UpdateEmployee(employeeChanges);

            if (result == 1)
            {
                return(this.Ok(employeeChanges));
            }
            else
            {
                Log.Error("This is a Bad Request");
                return(this.BadRequest());
            }
        }
Пример #11
0
        static void Main(string[] args)
        {
            //Retrieve url path of HelloWorldAPI
            string urlPath = ConfigurationManager.AppSettings["HelloWorldAPIURL"];

            //Resolve instance of Interface
            var container = new LightInject.ServiceContainer();

            container.Register <IErrorLogger, ErrorLogger>();
            var logger = container.GetInstance <IErrorLogger>();

            IFileLog fileLog = new FileLogger();

            var client = new RestClient(urlPath);

            try
            {
                //Execute the API Call
                IRestResponse response = client.Execute <List <HelloWorldController.Models.GreetingModel> >(new RestRequest());

                if (response != null)
                {
                    if (response.Content != null)
                    {
                        GreetingModel dataReceived = new GreetingModel();
                        dataReceived = JsonConvert.DeserializeObject <GreetingModel>(response.Content);
                        Console.WriteLine(dataReceived.greetingMessage);
                        Console.Read();
                    }
                    else
                    {
                        var errorMsg = "Error occured in restSharp. Error Message: " + response.ErrorMessage +
                                       "Error Status Description: " + response.StatusDescription;

                        //Log the error.
                        fileLog.WriteToFile(errorMsg);
                    }
                }
            }
            catch (Exception ex)
            {
                // Log the exception
                logger.DisplayErrorMessage(ex.InnerException.ToString());
            }
        }
Пример #12
0
        public void TestGreetingMessagePositiveScenario()
        {
            //Arrange your data

            //Arrange
            const string filePath    = "abc/samplepath";
            const string fileContent = "Hello World";

            //Create dependencies
            this.fileLoggerMock.Setup(m => m.ReadFile(filePath)).Returns(fileContent);

            expectedResult.greetingMessage = "Hello World";

            //Act
            GreetingModel gm = greetingData.GetGreetingMsg();

            //Assert
            Assert.AreEqual(expectedResult.greetingMessage, gm.greetingMessage);
        }
Пример #13
0
 public void UpdateEmployee(GreetingModel employeeChanges)
 {
     this._Manager.UpdateEmployee(employeeChanges);
 }
Пример #14
0
 public void InitTestSuite()
 {
     this.fileLoggerMock = new Mock <IFileLog>();
     expectedResult      = new GreetingModel();
     this.greetingData   = new GreetingData(this.fileLoggerMock.Object);
 }
Пример #15
0
 public Task <int> UpdateEmployee(GreetingModel employeeChanges)
 {
     return(this._repository.UpdateEmployee(employeeChanges));
 }
Пример #16
0
 public Task <int> AddEmployee(GreetingModel employee)
 {
     return(this._repository.AddEmployee(employee));
 }
Пример #17
0
 public void Update(GreetingModel employeeChanges)
 {
     _context.Employees.Update(employeeChanges);
 }
Пример #18
0
 public Task <int> Add(GreetingModel employee)
 {
     _context.Employees.Add(employee);
     return(_context.SaveChangesAsync());
 }
Пример #19
0
 public string Greeting(GreetingModel model) => new Writer().Greeting(model.Name);
Пример #20
0
 public GreetingModel Update(GreetingModel employeeChanges)
 {
     throw new NotImplementedException();
 }
Пример #21
0
 public GreetingModel Add(GreetingModel employee)
 {
     throw new NotImplementedException();
 }