Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Initiaze the global variable
 /// </summary>
 /// <param name="category">Selected category element</param>
 public CreateLabels_WorkflowCategory(WorkflowCategory category)
 {
     this.category = category;
 }