public async Task <List <WorkOrderNote> > GetNotesForWorkOrder(int id)
        {
            List <WorkOrderNote> notes = new List <WorkOrderNote>();

            using (var conn = new SqlConnection(_config["ConnectionStrings:DefaultConnection"]))
            {
                var cmd = new SqlCommand("pr_getWorkOrderNotesByWorkOrderId", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@workOrderId", id));

                conn.Open();
                await using (SqlDataReader reader = await cmd.ExecuteReaderAsync())
                {
                    while (reader.Read())
                    {
                        WorkOrderNote noteToAdd = new WorkOrderNote();

                        noteToAdd.Id                  = reader.GetInt32(reader.GetOrdinal("Id"));
                        noteToAdd.Note                = reader.GetString(reader.GetOrdinal("Note"));
                        noteToAdd.CreateDate          = reader.GetDateTime(reader.GetOrdinal("CreateDate"));
                        noteToAdd.CreatedBy.FirstName = reader.GetString(reader.GetOrdinal("FirstName"));
                        noteToAdd.CreatedBy.LastName  = reader.GetString(reader.GetOrdinal("LastName"));

                        notes.Add(noteToAdd);
                    }
                }
            }

            return(notes);
        }
示例#2
0
        public async Task <IActionResult> AddWorkOrderNote(WorkOrderNote workOrderNote)
        {
            var result = await _workOrderRepository.AddWorkOrderNote(workOrderNote);

            if (result == HttpStatusCode.Created)
            {
                return(StatusCode(201));
            }

            return(StatusCode(StatusCodes.Status500InternalServerError));
        }
        public async Task <HttpStatusCode> AddWorkOrderNote(WorkOrderNote workOrderNote)
        {
            HttpStatusCode httpStatus = (HttpStatusCode)500;

            using (var conn = new SqlConnection(_config["ConnectionStrings:DefaultConnection"]))
            {
                var cmd = new SqlCommand("pr_addWorkOrderNote", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@workOrderId", workOrderNote.WorkOrderId));
                cmd.Parameters.Add(new SqlParameter("@note", workOrderNote.Note));
                cmd.Parameters.Add(new SqlParameter("@createdBy", workOrderNote.CreatedBy.Id));

                conn.Open();
                await cmd.ExecuteNonQueryAsync();

                httpStatus = HttpStatusCode.Created;
            }

            return(httpStatus);
        }
示例#4
0
        public async Task <HttpStatusCode> AddWorkOrderNote(WorkOrderNote workOrderNote)
        {
            var result = await _workOrderDL.AddWorkOrderNote(workOrderNote);

            return(result);
        }