public bool UpdateProjectSourceType(ProjectSourceTypeObj item, string username) { if (!item.Id.HasValue) { return(false); } using (var db = GetInnerTrackContext()) { var dbItem = db.ProjectSourceTypes.SingleOrDefault(i => i.Id == item.Id.Value); if (dbItem == null) { return(false); } dbItem.Name = item.Name; dbItem.FullClassName = item.FullClassName; if (item.NextRun.HasValue) { dbItem.NextRun = item.NextRun.Value < SqlDateTime.MinValue.Value ? SqlDateTime.MinValue.Value : item.NextRun.Value; } if (item.LastRun.HasValue) { dbItem.LastRun = item.LastRun.Value; } dbItem.Enabled = item.Enabled; dbItem.Interval = item.Interval; dbItem.UpdatedBy = username; dbItem.UpdatedOn = DateTime.Now; db.SaveChanges(); return(true); } }
public int Create(ProjectSourceTypeObj obj, string username) { if (!obj.NextRun.HasValue) { obj.NextRun = DateTime.Now.AddMinutes(obj.Interval); } return(Repository.CreateProjectSourceType(obj, username)); }
internal static EditProjectSourceTypeModel ConvertToEdit(ProjectSourceTypeObj obj) { return(new EditProjectSourceTypeModel { Id = obj.Id, Name = obj.Name, FullClassName = obj.FullClassName, Interval = obj.Interval, Enabled = obj.Enabled }); }
public int CreateProjectSourceType(ProjectSourceTypeObj item, string username) { using (var db = GetInnerTrackContext()) { item.CreatedBy = username; item.CreatedOn = DateTime.Now; db.ProjectSourceTypes.Add(item); db.SaveChanges(); return(item.Id.Value); } }
internal static ShowProjectSourceTypeModel ConvertToShow(ProjectSourceTypeObj obj) { var model = new ShowProjectSourceTypeModel { Id = obj.Id.Value, Name = obj.Name, FullClassName = obj.FullClassName, Interval = obj.Interval, LastRun = obj.LastRun, NextRun = obj.NextRun.Value, Enabled = obj.Enabled }; return(model); }
public void Create_Successfully_Made() { //arrange int expected = 4; var mockRepository = new Mock <IInnerTrackRepository>(); var obj = new ProjectSourceTypeObj(); var user = "******"; mockRepository.Setup(m => m.CreateProjectSourceType(obj, user)).Returns(expected); var logic = new ProjectSourceTypeLogic(mockRepository.Object); //act var actual = logic.Create(obj, user); //assert Assert.AreEqual(expected, actual); }
public void Get_Id_Not_Found() { //arrange int id = 0; ProjectSourceTypeObj expected = null; var mockRepository = new Mock <IInnerTrackRepository>(); mockRepository.Setup(m => m.GetProjectSourceTypes(It.Is <ProjectSourceTypeFilter>(f => f.Id == id))).Returns(new List <ProjectSourceTypeObj> { }); var logic = new ProjectSourceTypeLogic(mockRepository.Object); //act var actual = logic.Get(id); //assert Assert.AreEqual(expected, actual); }
public void Update_Id_Found() { //arrange bool expected = true; var mockRepository = new Mock <IInnerTrackRepository>(); var updatedObj = new ProjectSourceTypeObj { Id = 2 }; var user = "******"; mockRepository.Setup(m => m.UpdateProjectSourceType(updatedObj, user)).Returns(expected); var logic = new ProjectSourceTypeLogic(mockRepository.Object); //act var actual = logic.Update(updatedObj, user); //assert Assert.AreEqual(expected, actual); }
public void GetAll_ProjectSourceTypes_Found() { //arrange var mockRepository = new Mock <IInnerTrackRepository>(); var expected = new ProjectSourceTypeObj() { Id = 2 }; mockRepository.Setup(m => m.GetProjectSourceTypes(It.Is <ProjectSourceTypeFilter>(f => !f.Id.HasValue))).Returns(new List <ProjectSourceTypeObj>() { expected }); var logic = new ProjectSourceTypeLogic(mockRepository.Object); //act var actual = logic.GetAll(); //assert Assert.IsNotNull(actual); Assert.AreEqual(1, actual.Count); Assert.AreEqual(2, actual[0].Id); }
public bool Update(ProjectSourceTypeObj obj, string username) { return(Repository.UpdateProjectSourceType(obj, username)); }