/// <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); }
public ViewResult Index(string name) { var model = new GreetingModel(); model.Name = name; return(View(model)); }
/// <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); }
public ActionResult Index() { var model = new GreetingModel { Greeting = "Welcome to the world of MVC", Name = "Your friendly neighborhood MVC App" }; return(View(model)); }
public IActionResult Index() { GreetingModel model = new GreetingModel() { CreateDate = DateTime.Now, Id = 1, Message = _greeting.GetMessageOfDay() }; return(View(model)); }
public GreetingModel Delete(int Employeeid) { GreetingModel model = _context.Employees.Find(Employeeid); if (model != null) { _context.Employees.Remove(model); } _context.SaveChanges(); return(model); }
/// <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); }
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()); } }
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()); } }
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()); } }
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()); } }
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); }
public void UpdateEmployee(GreetingModel employeeChanges) { this._Manager.UpdateEmployee(employeeChanges); }
public void InitTestSuite() { this.fileLoggerMock = new Mock <IFileLog>(); expectedResult = new GreetingModel(); this.greetingData = new GreetingData(this.fileLoggerMock.Object); }
public Task <int> UpdateEmployee(GreetingModel employeeChanges) { return(this._repository.UpdateEmployee(employeeChanges)); }
public Task <int> AddEmployee(GreetingModel employee) { return(this._repository.AddEmployee(employee)); }
public void Update(GreetingModel employeeChanges) { _context.Employees.Update(employeeChanges); }
public Task <int> Add(GreetingModel employee) { _context.Employees.Add(employee); return(_context.SaveChangesAsync()); }
public string Greeting(GreetingModel model) => new Writer().Greeting(model.Name);
public GreetingModel Update(GreetingModel employeeChanges) { throw new NotImplementedException(); }
public GreetingModel Add(GreetingModel employee) { throw new NotImplementedException(); }