public WorkflowRoleModel AddWorkflowRole(WorkflowRoleModel data) { WorkflowRole model = _mapper.Map <WorkflowRole>(data); var result = _context.WorkflowRole.Add(model); _context.SaveChanges(); return(_mapper.Map <WorkflowRoleModel>(result.Entity)); }
public WorkflowRoleModel UpdateWorkflowRole(WorkflowRoleModel data) { try { return(_repository.UpdateWorkflowRole(data)); } catch (Exception e) { Console.WriteLine(e); throw; } }
public WorkflowRoleModel UpdateWorkflowRole(WorkflowRoleModel data) { var result = _context.WorkflowRole.FirstOrDefault(a => a.Id == data.Id); if (result == null) { throw new KeyNotFoundException("Item cant be found"); } //result = _mapper.Map<WorkflowRole>(data, opt => opt.CreateInstance<UpdateProfile>()); Mapping.MapWorkflowRole(result, data); _context.SaveChanges(); return(data); }
public IActionResult Put([FromBody] WorkflowRoleModel model) { try { var result = _service.UpdateWorkflowRole(model); return(Ok(result)); } catch (Exception e) { Console.WriteLine(e); return(BadRequest($"{e.Message}")); } }
public void Test_Update_WorkflowRole() { //mock var model = new WorkflowRoleModel { Id = 1, Name = "Test" }; var mock = new Mock <IWorkflowRoleRepository>(); mock.Setup(p => p.UpdateWorkflowRole(model)).Returns(model); IWorkflowRoleService ser = new WorkflowRoleSercive(mock.Object); var result = ser.UpdateWorkflowRole(model); Assert.AreEqual(1, result.Id); Assert.AreEqual("Test", result.Name); }
public void Test_Add_WorkflowRole() { //mock var excepcted = new WorkflowRoleModel { Id = 1, Name = "Test" }; var mock = new Mock <IWorkflowRoleRepository>(); mock.Setup(p => p.AddWorkflowRole(excepcted)).Returns(excepcted); //Initialization IWorkflowRoleService ser = new WorkflowRoleSercive(mock.Object); //excpeted?? //Exec var result = ser.AddWorkflowRole(excepcted); //Assertion Assert.AreEqual("Test", result.Name); }
public void Test_GetById_WorkflowRole() { //mock var excepcted = new WorkflowRoleModel { Id = 1, Name = "Test" }; var mock = new Mock <IWorkflowRoleRepository>(); mock.Setup(p => p.GetById(1)).Returns(excepcted); //Initialization IWorkflowRoleService ser = new WorkflowRoleSercive(mock.Object); //expected //?? //execution var result = ser.GetById(1); //Assertions Assert.AreEqual(1, result.Id); }
public IActionResult Edit(WorkflowRoleModel dt) { var result = _service.UpdateWorkflowRole(dt); return(View(result)); }
public IActionResult Add(WorkflowRoleModel dt) { var result = _service.AddWorkflowRole(dt); return(View(result)); }
public static void MapWorkflowRole(WorkflowRole ds, WorkflowRoleModel sc) { ds.Name = sc.Name; }