public void DeleteSingle(int Id) { NbkDbEntities dbcontext = new NbkDbEntities(); WorkflowCategory Obj = dbcontext.WorkflowCategory.Where(x => x.Id == Id).FirstOrDefault(); dbcontext.WorkflowCategory.Remove(Obj); dbcontext.SaveChanges(); }
public WorkflowCategoryENT SelectSingle(int Id) { NbkDbEntities dbcontext = new NbkDbEntities(); WorkflowCategory Obj = dbcontext.WorkflowCategory.Where(x => x.Id == Id).FirstOrDefault(); WorkflowCategoryENT Data = new WorkflowCategoryENT() { Id = Obj.Id, Name = Obj.Name, IsDefault = Obj.IsDefault }; return(Data); }
public WorkflowCategoryENT CreateSingle(WorkflowCategoryENT Obj) { NbkDbEntities dbcontext = new NbkDbEntities(); WorkflowCategory Data = new WorkflowCategory() { Name = Obj.Name, IsDefault = Obj.IsDefault }; dbcontext.WorkflowCategory.Add(Data); dbcontext.SaveChanges(); Obj.Id = Data.Id; return(Obj); }
public HttpResponseMessage Delete(WorkflowCategory workflowCategory) { if (_repository.DeleteWorkflowCategory(workflowCategory.WorkflowCategoryID)) { DataSourceResult result = new DataSourceResult { Data = new[] { workflowCategory }, Total = 1 }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, result); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = workflowCategory.WorkflowCategoryID })); return(response); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } }
public int AddWorkflowCategory(WorkflowCategory toInsert) { int rowAffected = 0; using (var connection = new SqlConnection(PrescienceRxConnectionString)) { connection.Open(); using (SqlCommand command = connection.CreateCommand()) { command.CommandText = @"INSERT INTO dbo.WorkflowCategory VALUES (@CategoryName); SELECT CAST(SCOPE_IDENTITY() AS INT);"; command.Parameters.AddWithValue("@CategoryName", toInsert.CategoryName); rowAffected = (int)command.ExecuteScalar(); } connection.Dispose(); } return(rowAffected); }
public WorkflowCategoryENT UpdateSelectSingle(WorkflowCategoryENT Obj) { NbkDbEntities dbcontext = new NbkDbEntities(); WorkflowCategory Data = new WorkflowCategory() { Id = Obj.Id, Name = Obj.Name, IsDefault = Obj.IsDefault }; dbcontext.WorkflowCategory.Attach(Data); var update = dbcontext.Entry(Data); update.Property(x => x.Name).IsModified = true; update.Property(x => x.IsDefault).IsModified = true; dbcontext.SaveChanges(); return(Obj); }
public bool EditWorkflowCategory(WorkflowCategory toUpdate) { int rowAffected = 0; using (var connection = new SqlConnection(PrescienceRxConnectionString)) { connection.Open(); using (SqlCommand command = connection.CreateCommand()) { command.CommandText = @"UPDATE dbo.WorkflowCategory SET CategoryName = @CategoryName WHERE WorkflowCategoryID = @WorkflowCategoryID"; command.Parameters.AddWithValue("@WorkflowCategoryID", toUpdate.WorkflowCategoryID); command.Parameters.AddWithValue("@CategoryName", toUpdate.CategoryName); rowAffected = command.ExecuteNonQuery(); } connection.Dispose(); } return(rowAffected == 1 ? true : false); }
/// <summary> /// Initiaze the global variable /// </summary> /// <param name="category">Selected category element</param> public CreateLabels_WorkflowCategory(WorkflowCategory category) { this.category = category; }